minor improvements to suggested edits
This commit is contained in:
@ -423,7 +423,7 @@
|
||||
"With JavaScript <code>array</code> variables, we can store several pieces of data in one place.",
|
||||
"You start an array declaration with an opening square bracket, end it with a closing square bracket, and put a comma between each entry, like this: <code>var sandwich = [\"peanut butter\", \"jelly\", \"bread\"]</code>.",
|
||||
"Now let's create a new array called <code>myArray</code> that contains both a <code>string</code> and a <code>number</code> (in that order).",
|
||||
"Refer to the comments if you get stuck."
|
||||
"Refer to the commented code in the text editor if you get stuck."
|
||||
],
|
||||
"tests": [
|
||||
"assert(typeof(myArray) == 'object', '<code>myArray</code> should be an <code>array</code>.');",
|
||||
@ -450,7 +450,7 @@
|
||||
"title": "Nest one Array within Another Array",
|
||||
"difficulty":"9.98161",
|
||||
"description":[
|
||||
"You can also nest arrays within other arrays, like this: <code>[[\"Bulls\", 43]]</code>.",
|
||||
"You can also nest arrays within other arrays, like this: <code>[[\"Bulls\", 23]]</code>.",
|
||||
"Let's now go create a nested array called <code>myArray</code>."
|
||||
],
|
||||
"tests":[
|
||||
@ -894,7 +894,7 @@
|
||||
"",
|
||||
" return 0;",
|
||||
"",
|
||||
"// Only change code above this line.",
|
||||
" // Only change code above this line.",
|
||||
"}",
|
||||
"",
|
||||
"// We use this function to show you the value of your variable in your output box.",
|
||||
@ -944,8 +944,8 @@
|
||||
"difficulty":"9.9829",
|
||||
"description":[
|
||||
"We can use a certain mathematical expression to get a random number between two numbers.",
|
||||
"<code>Math.floor(Math.random() * (max - min + 1)) + min</code>. More info about how it works <a href=\"https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Waypoint-Generate-Random-Whole-Numbers-within-a-Range#explanation\">here</a>.",
|
||||
"By using this we can control the output of a random number."
|
||||
"<code>Math.floor(Math.random() * (max - min + 1)) + min</code>",
|
||||
"By using this, we can control the output of a random number."
|
||||
],
|
||||
"tests":[
|
||||
"assert(myFunction() >= min, 'The random number that\\'s generated by myFunction should be greater than or equal to the minimum number');",
|
||||
@ -972,20 +972,19 @@
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c12feddfaeb3bdef",
|
||||
"title": "Use Conditional Logic with If-Else Statements",
|
||||
"title": "Use Conditional Logic with If and Else Statements",
|
||||
"difficulty":"9.983",
|
||||
"description":[
|
||||
"We can use if statements in JavaScript to only execute code if a certain condition is met.",
|
||||
"if statements require some sort of boolean condition to evaluate.",
|
||||
"Example:",
|
||||
"We can use <code>if</code> statements in JavaScript to only execute code if a certain condition is met.",
|
||||
"<code>if</code> statements require some sort of boolean condition to evaluate.",
|
||||
"For example:",
|
||||
"<code> if (1 === 2) {</code>",
|
||||
"<code>  return true;</code>",
|
||||
"<code>}</code>",
|
||||
"<code>else {</code>",
|
||||
"<code>} else {</code>",
|
||||
"<code>  return false;</code>",
|
||||
"<code>}</code>",
|
||||
"Let's use <code>if</code> and <code>else</code> statements to make a coin-flip game.",
|
||||
"Create an <code>if-else statement</code> to return <code>heads</code> if the flip var is zero, or else return <code>tails</code> if it's not."
|
||||
"Create <code>if</code> and <code>else</code> statements to return the string <code>\"heads\"</code> if the flip variable is zero, or else return the string <code>\"tails\"</code> if the flip variable is not zero."
|
||||
],
|
||||
"tests":[
|
||||
"assert((function(){var result = myFunction();if(result === 'heads' || result === 'tails'){return true;} else {return false;}})(), '<code>myFunction</code> should either return <code>heads</code> or <code>tails</code>.');",
|
||||
@ -1022,8 +1021,8 @@
|
||||
"<code>the</code> is the pattern we want to match.",
|
||||
"<code>g</code> means that we want to search the entire string for this pattern instead of just the first match.",
|
||||
"<code>i</code> means that we want to ignore the case (uppercase or lowercase) when searching for the pattern.",
|
||||
"<code>Regular expressions</code> are written by surrounding the pattern with a <code>/</code> symbol.",
|
||||
"Let's try selecting all the occurrences of the word <code>and</code> in the string <code>George Boole and Alan Turing went to the shop and got some milk</code>. We can do this by replacing the <code>.</code> part of our regular expression with the current <code>regular expression</code> with the word <code>and</code>."
|
||||
"<code>Regular expressions</code> are written by surrounding the pattern with <code>/</code> symbols.",
|
||||
"Let's try selecting all the occurrences of the word <code>and</code> in the string <code>Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it</code>. We can do this by replacing the <code>.</code> part of our regular expression with the current <code>regular expression</code> with the word <code>and</code>."
|
||||
],
|
||||
"tests":[
|
||||
"assert(test==2, 'Your <code>regular expression</code> should find two occurrences of the word <code>and</code>.');",
|
||||
@ -1031,8 +1030,8 @@
|
||||
],
|
||||
"challengeSeed":[
|
||||
"var test = (function() {",
|
||||
" var testString = \"George Boole and Alan Turing went to the shop and got some milk\";",
|
||||
" var expressionToGetMilk = /milk/gi;",
|
||||
" var testString = \"Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it.\";",
|
||||
" var expressionToGetSoftware = /software/gi;",
|
||||
" // Only change code below this line.",
|
||||
"",
|
||||
" var expression = /./gi;",
|
||||
|
Reference in New Issue
Block a user