Javascript 20. Not sure what's wrong with my code


Step 20 is on modulo. I checked and it looks like the code for modulo I put in should work but the console keeps giving me error message. Here's my code:

console.log("14 % 3");
console.log("99 % 8");
console.log("11 % 3");


Perhaps that error message says something about what you need to change?

Or perhaps the behaviour of the program is in some way different from what you want to happen?

Consider those things and/or add them in your question. Never use the word "work" to describe what is going on! Explain what happens, and what you think should happen instead. Often those two things together say what needs to change, sort of like subtraction in math.. subtract the current situation from the desired result, and you get what modification is required.. sort of :stuck_out_tongue:


You have quotes ( " ) around the expressions. You don't want those.


Here is what it says, it doesn't really help me though:

Oops, try again. It looks like the first console.log() isn't quite right.

Checked a bunch of times didn't see anything wrong with it.


Oh ok, thanks. It didn't occur to me that I was writing strings instead of equations. :slightly_smiling:


Okay. If you read the instructions, do they in some way give you an idea of an expected result?
And if you look at what your program prints, what do you get?

@cadecodes seems to have nailed the problem, even so, we'll always run into new ones so we gotta figure out how to solve them!


Yes, they do give me an idea of expected results. The results i got are 2, 3, and 2. The code ran fine after @cadecodes found the bug.


What we've got:
The expression got printed

What we want:
You want the result of the expression.

So the difference between those two, is that you need that expression to evaluate.
Which tells us what we need to change, but not how to do it. But it's enough to know what to google for or similar, right.

And then we figure out that to evaluate an expression, as opposed to treating it as text, we need it to not be a string.


Ok. thanks for your help, @ionatan, @cadecodes :slightly_smiling: