Comparison with the Equality Operator

pull/18182/head
Abhisek Pattnaik 2015-12-26 09:24:16 +05:30 committed by SaintPeter
parent b48e7b7874
commit bef9d5561a
1 changed files with 5 additions and 5 deletions

View File

@ -2276,14 +2276,14 @@
"id": "56533eb9ac21ba0edf2244d0",
"title": "Comparison with the Equality Operator",
"description": [
"There are many <dfn>Comparison Operators</dfn> in Javascript. All of these operators return a boolean <code>true</code> or <code>false</code> value.",
"The most basic operators is the equality operator <code>==</code>. The equality operator compares to values and returns true if they're equivilent or false if they are not. Note that equality is different from assignement (<code>=</code>), which returns the value to the right of the operator.",
"<blockquote>function equalityTest(myVal) {<br /> if (myVal == 10) {<br /> return \"Equal\";<br /> }<br /> return \"Not Equal\";<br />}</blockquote>",
"There are many <dfn>Comparison Operators</dfn> in JavaScript. All of these operators return a boolean <code>true</code> or <code>false</code> value.",
"The most basic operator is the equality operator <code>==</code>. The equality operator compares two values and returns <code>true</code> if they're equivalent or <code>false</code> if they are not. Note that equality is different from assignment (<code>=</code>), which assigns the value at the right of the operator to a variable in the left.",
"<blockquote>function equalityTest(myVal) {<br> if (myVal == 10) {<br> return \"Equal\";<br> }<br> return \"Not Equal\";<br>}</blockquote>",
"If <code>myVal</code> is equal to <code>10</code>, the function will return \"Equal\". If it is not, the function will return \"Not Equal\".",
"The equality operator will do it's best to convert values for comparison, for example:",
"<blockquote> 1 == 1 // true<br> \"1\" == 1 // true<br /> 1 == '1' // true<br /> 0 == false // true<br> 0 == null // false<br> 0 == undefined // false<br> null == undefined // true</blockquote>",
"<blockquote> 1 == 1 // true<br> \"1\" == 1 // true<br> 1 == '1' // true<br> 0 == false // true<br> 0 == null // false<br> 0 == undefined // false<br> null == undefined // true</blockquote>",
"<h4>Instructions</h4>",
"Add the <code>equality operator</code> to the indicated line so the function will return \"Equal\" when <code>val</code> is equivilent to <code>12</code>"
"Add the <code>equality operator</code> to the indicated line so that the function will return \"Equal\" when <code>val</code> is equivalent to <code>12</code>"
],
"releasedOn": "11/27/2015",
"tests": [