That’s not how if()-then commands work. The syntax is
if (expression-that-evaluates-to-true-or-false){doStuff()}else{doOtherStuff()}
Your code has if(true) on the third line, and since true is the javascript constant boolean true the condition will always evaluate to true, so the first block of code will get executed.
get rid of the semicolon on line 2 and all of line 3 and it should work.