Having trouble on Exercise 4 & 5
Us regulars cannot see this special repl. Can you post the code here, or put it in another repl? Thanks!
function exerciseFour(value){
let greaterThanFive = false;
// In this exercise, you will be given a variable, it will be called: value
// You will also be given a variable named: greaterThanFive
// Using an 'if' statement check to see if the value is greater than 5. If it is, re-assign greaterThanFive the boolean true.
if(value > 5); {
let greaterThanFive = true;
}
// Please write your answer in the line above.
return greaterThanFive;
}
function exerciseFive(name){
let isSondra = false;
// In this exercise, you will be given a variable, it will be called: name
// You will also be given a variable named: isSondra
// Using an 'if' statement check to see if the name is equal to the string 'Sondra'. If it is, re-assign isSondra the boolean true.
if(name === 'Sondra'){}
else;{}
// Please write your answer in the line above.
return isSondra;
}
Just a few simple changes:
Exercise Four:
if
and the partheses.let
inside theif
block.Like This:
Exercise Five:
Well, you cannot use
===
for comparing strings. You have to use theequals()
method. Like this:Sneaky Method: I don't know how your sytem grades your tests, but for both of these, there is a much faster way to do it:
If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!
@vedprad1
It is interesting to me that your example for number 4 works in the system, but to solve number 5 in the system it requires (name === ('Sondra)) to work properly. That is the only way it will return a completed assignment.