Randell Dawson 05f73ca409 fix(curriculum): Convert blockquote elements to triple backtick syntax for JavaScript Algorithms and Data Structures (#35992)
* fix: convert js algorithms and data structures

* fix: revert some blocks back to blockquote

* fix: reverted comparison code block to blockquotes

* fix: change js to json

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: convert various section to triple backticks

* fix: Make the formatting consistent for comparisons
2019-05-17 08:20:30 -05:00

2.4 KiB

id, title, challengeType, videoUrl
id title challengeType videoUrl
56533eb9ac21ba0edf2244d2 Comparison with the Inequality Operator 1 https://scrimba.com/c/cdBm9Sr

Description

The inequality operator (!=) is the opposite of the equality operator. It means "Not Equal" and returns false where equality would return true and vice versa. Like the equality operator, the inequality operator will convert data types of values while comparing. Examples
1 !=  2     // true
1 != "1"    // false
1 != '1'    // false
1 != true   // false
0 != false  // false

Instructions

Add the inequality operator != in the if statement so that the function will return "Not Equal" when val is not equivalent to 99

Tests

tests:
  - text: <code>testNotEqual(99)</code> should return "Equal"
    testString: assert(testNotEqual(99) === "Equal", '<code>testNotEqual(99)</code> should return "Equal"');
  - text: <code>testNotEqual("99")</code> should return "Equal"
    testString: assert(testNotEqual("99") === "Equal", '<code>testNotEqual("99")</code> should return "Equal"');
  - text: <code>testNotEqual(12)</code> should return "Not Equal"
    testString: assert(testNotEqual(12) === "Not Equal", '<code>testNotEqual(12)</code> should return "Not Equal"');
  - text: <code>testNotEqual("12")</code> should return "Not Equal"
    testString: assert(testNotEqual("12") === "Not Equal", '<code>testNotEqual("12")</code> should return "Not Equal"');
  - text: <code>testNotEqual("bob")</code> should return "Not Equal"
    testString: assert(testNotEqual("bob") === "Not Equal", '<code>testNotEqual("bob")</code> should return "Not Equal"');
  - text: You should use the <code>!=</code> operator
    testString: assert(code.match(/(?!!==)!=/), 'You should use the <code>!=</code> operator');

Challenge Seed

// Setup
function testNotEqual(val) {
  if (val) { // Change this line
    return "Not Equal";
  }
  return "Equal";
}

// Change this value to test
testNotEqual(10);

Solution

function testNotEqual(val) {
  if (val != 99) {
    return "Not Equal";
  }
  return "Equal";
}