New course! Every coder should learn Generative AI!
Try a free lesson+ 1
The first reason is for not working it because in your code you have declared if(symbol= "/") that's why the symbol will become / so that's why your code won't work.
You should declare if(symbol=="/")
also you should print the answer either in alert or console, not both.
The second reason is like @Allan told you.You should parse your input as an int or float to get the accurate answer.
After fixing your code,it would be something like this:
https://code.sololearn.com/Wa4A14a25A11
+ 5
because in javascript '+' is used for string concatenation, to use the sign as a plus symbol you do thd following :
1. write your code in HTML and use &plus then use DOM in javascript to access the attribute in HTML
or
2. in your javascript code parse your input as integers since they are treated as strings, convert them to integers first before using them in the + part