0
Checking an if statement to see if a number is greater than another
Iāve been given an question āwrite an if statement that checks to see if number is greater than 22. If it is then it should assign āThis number is greater than 22ā to message. Line 2 is: var number = 29; Line 3 is: var message = āthis number is smaller than 22ā... Every time I write the if statement and change smaller than to greater than as instructed I get an error.. How can I fix this ?
18 Respostas
+ 2
Nguyį»
n VÄn HoĆ ng wow!! thank you so much . i missed that completely š¤¦š¾āāļø
+ 2
Nguyį»
n VÄn HoĆ ng your a rockstar . I had everything except for else and the 2nd result . your a rockstar man šš thank you.
+ 2
Nguyį»
n VÄn HoĆ ng I get the same answers but for some reason my time on site brings errors i email them and they told me , im sorry we gonna fix that refresh in another 20 mins. they told me i wasnt the only one having problems. šš¾
+ 1
Your if statement should work when tried it with a different number.') <ā thats the error message Nguyį»
n VÄn HoĆ ng
+ 1
Junie B. That sounds more like a message from a code-learning site than a message issued by the interpreter. I haven't seen your if statement yet, there is a possibility that you didn't get their assignment right.
Sorry I'm still unable to help. Is this a quiz on SoloLearn? If not, would you mind telling me which IDE you were working with and which platform/browser you were testing on?
+ 1
// your code below here
if ('number > 22'); Nguyį»
n VÄn HoĆ ng
+ 1
Junie B. there are quotation marks around your condition, which makes it a string, and the block that follows will always be executed.
if ('number > 22') // Logical Error
if (number > 22) // Correct
+ 1
Junie B.
var number = 28;
var message = 'This number is smaller than 22';
// your code below here
if (number > 22)
message = 'This number is greater than 22';
+ 1
Nguyį»
n VÄn HoĆ ng sorry but can i trouble you for one more. im studying and i really want to understand
+ 1
Junie B. feel free to go.
+ 1
Junie B.
// your code below here
if (number > 100 && number < 2000)
result = message1;
else
result = message2;
+ 1
Nguyį»
n VÄn HoĆ ng have anything for this https://foundations.nycda.tools/challenges/required-exercise-looping-part-2
+ 1
let basket = ['banana', 'mango', 'cucumber', 'peach', 'apple'];
for (let fruit in basket)
console.log(fruit);
The instructions on the site seems clear to me, which part of it you didn't understand? It would be uneffective if we go on like this. Programming is about the concepts, not the syntax.
0
Can you provide the full error message or a link to your code? Line 2 and Line 3 contain no error from my observation.
0
Nguyį»
n VÄn HoĆ ng thank you, but everytime I insert the correct condition it shows im wrong with āyour if statement should work when tried it with a different number.ā) and when i change my message to āthis number is smaller than 22ā it say my condition is incorrect. its very confusing. sidenote my number is 28 āVar number = 28;ā
0
Junie B. sorry for taking your time. Since this is taken out of context, I'd suggest you show the whole program (what the site already done for you and also your solution) or link to where you were having the problem.