Filtering a dataset and disabling the addition of any similar new entries

I am trying to write a code that goes through a dataset and disable the addition of any entry that is identical to an entry already existing in the dataset by disabling the add button. I keep getting an error at the else line.
I am really new to coding so I would really appreciate your help.

function filter ( class1 , title ) {
let new filter = wixData . filter ();
if ( class1 ) {
new filter = new filter . contains ( “Class1” , class1 )
}
if ( title ) {
new filter = new filter . contains ( “First Name” , title )
}
$w ( “#dataset1” ). setFilter ( newfilter );
function onChange() {
$w ( “#button1” ). disable ()

else {
$w ( “#button1” ). enable ();
}
}

I would suggest visiting the following sites for information on programming in Javascript:

To learn about programming with Velo, read the following articles that will help you start working with Velo:

See the No Database Duplicates example to see how this can be done.