JS Assignment 3
DdGen (0)

Having trouble on Exercise 4 & 5

https://repl.it/student/submissions/7232739

You are viewing a single comment. View All
vedprad1 (727)

Just a few simple changes:

Exercise Four:

  1. There should be a space between if and the partheses.
  2. There should not be a semicolon after the parentheses.
  3. You do not need another let inside the if block.
    Like This:
function exerciseFour(value) {
  let greaterThanFive = false;
  if (value > 5) {
    greaterThanFive = true;
  }
  return greaterThanFive;
}

Exercise Five:

Well, you cannot use === for comparing strings. You have to use the equals() method. Like this:

function exerciseFive(name) {
  let isSondra = false;
  if (name.equals('Sondra')) {
    isSondra = true;
  }
  return isSondra;
}

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:

function exerciseFour(value) {
  return value > 5;
}

function exerciseFive(name) {
  return name.equals('Sondra');
}

If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!