How do I write a basic if else, concise version, complete statement?


#1
const visibleLightWaves = () => {
  let lightWaves = 'Moonlight';
  let region = 'The Arctic';
  if (region === 'The Arctic ') console.log('The Arctic');} else {console.log('other');}
  console.log(lightWaves);
};

visibleLightWaves();

Specifically the if else statement is wrong…I have consistently been getting it wrong and all the other answers are focusing on a different part of the exercise that I have not achieved yet.

Hopefully I chose the correct category!


#2

Missing opening curly brace after the condtion.

Make liberal use of white space. Scrunched up code is not easy to read, makes it difficult to spot errors, and does not make code any better or more efficient.

if (...) {

} else {

}

#3
const visibleLightWaves = () => {
  
let lightWaves = 'Moonlight';

  let region = 'The Arctic';

  if (region ='The Arctic') {console.log(true);}

  console.log(lightWaves);

};

visibleLightWaves();

Above is my new attempt (with more space as suggested!). I must be interpreting the instructions wrong or missing syntax that I do not realize I am missing.

I forgot to add the link… here is the link: https://www.codecademy.com/courses/learn-javascript-scope/lessons/scope/exercises/block-scope-ii?action=lesson_resume&course_redirect=introduction-to-javascript

Am I supposed to include an else statement too? The instructions state:
Beneath the region variable, create an if statement that checks if the region is the 'The Arctic'.


#4

Nevermind, I was able to figure it out through trial and error.:sunglasses:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.