Good day everyone. I just started the javascript course on FCC so decided to try some personal practice as i go through the course. However, my very first function has been returning undefined in the console. Please can anyone assist with reason behind this.
Below is my code. Thank you.IMG_20201202_102919|536x499
hii may be this code can help you
function evendetect(num){
if(num % 2 == 0){
alert("even");
}else{
alert("odd");
}
}
evendetect(10);
Hi @twikista. Welcome to the FCC community. If you want to ask a question, Copy and paste your code here instead of adding a link to an image. You can do it as follows:
You are getting undefined
because =
is not a comparison operator. You should instead use ==
or ===
for comparison.
Hi @GodfatherOPP. Welcome to FCC. I have edited your post. Check my response above on how to enter a block of code on the forum for readability.
Thank you for bringing this to my attention. Will keep learning learning how to use the forum.
1 Like
Thank you very much. Solved.
Thank you so much. Solved.