Use Conditional Logic with If Statements

pull/5525/head
Abhisek Pattnaik 2015-12-26 08:45:33 +05:30 committed by SaintPeter
parent 93d6ff2bea
commit cba48287ff
1 changed files with 7 additions and 7 deletions

View File

@ -2223,12 +2223,12 @@
"title": "Use Conditional Logic with If Statements",
"description": [
"We can use <code>if</code> statements in JavaScript to only execute code if a certain condition is met.",
"<code>if</code> statements require a boolean condition to evaluate. If the boolean evaluates to true, the statement inside the curly braces executes. If it evaluates to false, the code will not execute.",
"<code>if</code> statements require a <dfn>boolean</dfn> condition to evaluate. If the boolean evaluates to <code>true</code>, the statement inside the curly braces executes. If it evaluates to <code>false</code>, the code will not execute.",
"For example:",
"<blockquote>function test(myVal) {<br /> if (myVal > 10) {<br /> return \"Greater Than\";<br /> }<br /> return \"Not Greater Than\";<br />}</blockquote>",
"If <code>myVal</code> is greater than <code>10</code>, the function will return \"Greater Than\". If it is not, the function will return \"Not Greater Than\".",
"<blockquote>function test(myVal) {<br> if (myVal > 10) {<br> return \"Greater Than\";<br> }<br> return \"Not Greater Than\";<br>}</blockquote>",
"If <code>myVal</code> is greater than <code>10</code>, the function will return <code>\"Greater Than\"</code>. If it is not, the function will return <code>\"Not Greater Than\"</code>.",
"<h4>Instructions</h4>",
"Create an <code>if</code> statement inside the function to return <code>\"Yes\"</code> if <code>testMe</code> is greater than <code>5</code>. Return <code>\"No\"</code> if it is less than <code>5</code>."
"Create an <code>if</code> statement inside the function to return <code>\"Yes\"</code> if <code>testMe</code> is greater than <code>5</code>. Return <code>\"No\"</code> if it is less than or equal to <code>5</code>."
],
"tests": [
"assert(typeof myFunction === \"function\", 'message: <code>myFunction</code> should be a function');",
@ -2251,9 +2251,9 @@
"function myFunction(testMe) {",
"",
" // Only change code below this line.",
"",
"",
"",
" ",
" ",
" ",
" // Only change code above this line.",
"",
"}",