Back to Freecodecamp

Step 11

curriculum/challenges/english/blocks/workshop-logic-checker-app/690a3ad44874a928a2fe3077.md

latest1.6 KB
Original Source

--description--

Comparison operators allow you to compare values and write more complex conditional statements.

js
if (today == birthday) {
  console.log("Happy Birthday!");
}

For example, the code above logs "Happy Birthday!" to the console only when the values of the variables today and birthday are equal.

Create a third if statement. For its condition, use the >= operator to check if timmyAge is greater than or equal to 16.

Inside the body of your new if statement, log "Timmy is old enough to drive." to the console.

--hints--

You should have a third if statement in your code.

js
assert.match(__helpers.removeJSComments(code), /const\s+timmyAge\s*\=\s*.+\bif\s*\(.+\)\s*\{.+\}/s);

Your third if statement should use timmyAge >= 16 as its condition.

js
assert.match(__helpers.removeJSComments(code), /const\s+timmyAge\s*\=\s*.+\bif\s*\(\s*timmyAge\s*>=\s*16\s*\)\s*\{.+\}/s);

You should log "Timmy is old enough to drive." to the console inside your third if statement.

js
assert.match(__helpers.removeJSComments(code), /const\s+timmyAge\s*\=\s*.+\bif\s*\(\s*timmyAge\s*>=\s*16\s*\)\s*\{\s*console\s*\.\s*log\s*\(\s*('|"|`)Timmy is old enough to drive.\1\s*\)\s*;?\s*\}/s);

--seed--

--seed-contents--

js
const hasDeveloperJob = true;

if (hasDeveloperJob) {
  console.log("Timmy is employed as a developer.");
}

const isTimmyAGamer = false;

if (isTimmyAGamer) {
  console.log("Timmy loves to play World of Warcraft.");
}

const timmyAge = 18;

--fcc-editable-region--

--fcc-editable-region--