Basic JavaScript: Introducing Else Statements

Tell us what’s happening:
I worked out the answer and it didn’t work. I checked the HINT and my answer was the same as yours and it still didn’t work. So, I copied your answer and posted it on the lesson and it still didn’t work. You apparently have a flaw that particular questions formula. So, how do I get past this question so I can continue my studies? I finally found out how to skip the question. I did check my work in my JavaScript console browser and my work was correct. I do hope someone is paying attention as there is definitely a problem with that questions secret answer.

Your code so far

function testElse(val) {

var result = “”;

// Only change code below this line

if (val > 5) {

result = “Bigger than 5”;

} else {

result = “5 or Smaller”;

}

// Only change code above this line

return result;

}

// Change this value to test

testElse(4);
        
```js

function testElse(val) {
var result = “”;
// Only change code below this line

if (val > 5) {
result = “Bigger than 5”;
} else {
result = “5 or Smaller”;
}

// Only change code above this line
return result;
}

// Change this value to test
testElse(4);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0.

Challenge: Introducing Else Statements

Link to the challenge:

Hello and welcome to the forum!

It looks like your keyboard has inserted ‘smart qotes’ (“”), but you need to use regular quotes ("").

1 Like

I’m guessing that you are using an Apple device. Apple likes those pretty curly quotes that are not actually the same character as quotation marks. If you’re on an Apple device, you need to turn off “smart punctuation”. You’ll see the same result if you write your code in a word processor (like MS Word) and copy it out. A simple text editor (like notepad) will not do weird formatting stuff.

1 Like