What's wrong with this piece of code?


#1


I am on Learn JacaScript, exercise 4: Math Operators, #2


The first exercise asks you to add 3.5 to your age using console.log, and I entered
console.log('19+3.5')
and it worked. The second exercise asks you to subtract 1969 from 2017 using console.log, and I entered
console.log('2017-1969')
and it didn't work. I've run it many times and it says "It has been 48 years since the 1969 moon landing. Did you log that answer to the console?" I don't know what's wrong.


console.log('2017-1969')


#2

I added ; on the end of both pieces and console.log('19+3.5'); still worked while console.log('2017-1969'); still didn't.


#3

we use ' ' for string

remove the ' ' to get the result


#4

Thank you so much! That fixed it :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.