JS Assignment 3
DdGen (4)

Having trouble on Exercise 4 & 5


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

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!

ARCompton14 (0)


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.