How to make this code work ?

This isn't working How to change "+" into just + Here, https://code.sololearn.com/W17lrO6J9bOU/?ref=app

12/7/2018 4:58:26 AM


6 Answers

New Answer


console.log(eval('1+ 1')); alert(eval('1 + 1'));


If you want only to print string then you can use this console.log(eval(new String('2 + 2')));


I wanted to do that differently


I know that. I want to do that separately. How to change "+" into just +


Do you mean that you want to output the + sign directly? Like showing 1+1 in the alert box?


let sum = 2; alert("1 + 1 = " + sum); you can also use a string template without having to enclose the string in quotes and adding the + to concatenate. the syntax uses the back tick (shift+~) which is not available on my iPhone keyboard so I will use a single quote here. just enclose the entire expression in back ticks. Enclose your variables in ${} and it will be concatenated. alert(‘1 + 1 = ${sum}’)