Hi there, i got stuck along the line please help, Question asked to write an if/else satatement


#1

if(20 == 3)
{
console.log("There is no class.");
}
else
{
console.log("We have class tomorrow.");


#2

@robbiehey28gmail_com,

Don't kick yourself over this, but it's pretty simple.

You're simply missing a closing bracket " } " at the end of your code. This is suppose to close your "else" statement, so the console knows where to stop when reading your code!

else
{
console.log("We have class tomorrow.");
//Missing closing bracket here!

I hope this helps and sorry for the long wait for a response!


#3

So do you see the issue here? It's not letting this through.

if (5 = 3 + 2)
{
console.log("I finished my first course");
}
else
{
console.log("How'd that work?");
}


#4

Hi Lolman,

My code is as follows: I am still not where the error is

// Remember, the order and punctuation matter.
// If you get an error, check carefully, line by line.
// If you're really stuck, click "Stuck? Get a hint!"
if(20 == 3)
{
console.log("There is no class.");
}
else
{
console.log("We have class tomorrow.");
}


#5

Hi Toy500
I don't really get your point can you explain a little bit more, I am a new into coding.Thanks


#6

I did put a closing bracket at the end of my coding, still getting an error : It looks like your if/else statement didn't log 2the condition is false to the console.


#7

I believe you're on "16. More practice with conditionals" correct?

The instructions are as follows:


  1. Write an if/else statement, just like we did in the last exercise.


  2. If your condition is true, use console.log to print "The condition is true".


  3. Otherwise (else) when it is false, use console.log to print "The condition is false".


  4. Make sure your condition evaluates to false, so that your program prints out "The condition is false".



So you made your if statement false so it'd print the "else" statement. However you aren't printing "The condition is false" to the console. Remember everything is case sensitive, and is expecting a character for character match in the console.log statement. Keep this in mind later because this sort of thing happens in a lot of lessons, and in every language.

This is practice because coding in general is this picky about cases, and this helps teach attention to detail! :+1:


#8

Excuse me, lolman, could explain why in JavaScript 19 this line of code is not working:

if("Jon".length * 2 / (2+1) === 2 )
{
console.log("true!");
}
else
{
console.log("Error Error Error");
}

It keeps telling me "Oops, try again. Make sure your if/else statement evaluates to true!" I clicked the "Stuck? Get a hint!" button multiple times and have refreshed my browser and repeated the problem over and over again. Thanks in advance for helping me!


#9

@yayacodes,

I hate to say it, but the reason you're failing is because you changed the console.log statement to "true!" instead of what it was. "The answer makes sense!". Change it back to "The answer makes sense!" and you will be good to go.

When it says to evaluate to "true" it means that the if statement will run the code it's been assigned.


#10

Hi Lolman,

Yes I am on more practice with conditionals. Can you please help me understand this; let me say if the condition is true, I have to use console.log to print "the condition true right". Now the condition true is been printed, am I suppose to print the else statement or I have to stop at the if statement. The other thing is that I was trying to go back to the previous if conditional to see how I did it but I don't know where do I click if I want to refer to the previous completed practice that could help also.


#11

Hi yayacodes,

Are you on conditional practice as well or what? It looks like you have already passed where i'm stuck at. Can you please help me there and site an example. I am a beginner in JS. Any luck with where you got stuck on your side? I wish I could be of good help, is a pity I am still a bit behind I wouldn't have a clue to help you. We will definitely get there. Good luck!


#12

You know, what I can see is that my code is printing the if statement only, the I get an error message saying my if/else statement didn't log" the condition is false."