If statement doesnt return the true or false propely

Tell us what’s happening:
hello guysn i have a problem when i tested this code on notepad++ and linked it with an html file, it always alerts " Not Equal " however : testEqual(12)
i really need some help

Your code so far

function testEqual(val) {
  if (val == 12) { 
    return "Equal";
  }
  return "Not Equal";
}


testEqual(12);

alert(testEqual());

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator

this function call does not have an argument so the if condition is undefined == 12, which correclty returns Not Equal

1 Like

so if i want to alert the condition i have to put:
alert();
instead of:
return;

Make a complete function call inside alert()

alert(testEqual(12))

2 Likes