diff --git a/challenges/01-front-end-development-certification/basic-javascript.json b/challenges/01-front-end-development-certification/basic-javascript.json
index e10ae3470f..36e16e288b 100644
--- a/challenges/01-front-end-development-certification/basic-javascript.json
+++ b/challenges/01-front-end-development-certification/basic-javascript.json
@@ -861,7 +861,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function convert(celsius) {",
+ "function convertToF(celsius) {",
" // Only change code below this line",
" ",
" ",
@@ -870,18 +870,18 @@
"}",
"",
"// Change the inputs below to test your code",
- "convert(30);"
+ "convertToF(30);"
],
"solutions": [
- "function convert(celsius) {\n var fahrenheit = celsius * 9/5 + 32;\n if ( typeof fahrenheit !== 'undefined' ) {\n return fahrenheit;\n } else {\n return 'fahrenheit not defined';\n }\n}"
+ "function convertToF(celsius) {\n var fahrenheit = celsius * 9/5 + 32;\n if ( typeof fahrenheit !== 'undefined' ) {\n return fahrenheit;\n } else {\n return 'fahrenheit not defined';\n }\n}"
],
"tests": [
- "assert(typeof convert(0) === 'number', 'message: convert(0)
should return a number');",
- "assert(convert(-30) === -22, 'message: convert(-30)
should return a value of -22
');",
- "assert(convert(-10) === 14, 'message: convert(-10)
should return a value of 14
');",
- "assert(convert(0) === 32, 'message: convert(0)
should return a value of 32
');",
- "assert(convert(20) === 68, 'message: convert(20)
should return a value of 68
');",
- "assert(convert(30) === 86, 'message: convert(30)
should return a value of 86
');"
+ "assert(typeof convertToF(0) === 'number', 'message: convertToF(0)
should return a number');",
+ "assert(convertToF(-30) === -22, 'message: convertToF(-30)
should return a value of -22
');",
+ "assert(convertToF(-10) === 14, 'message: convertToF(-10)
should return a value of 14
');",
+ "assert(convertToF(0) === 32, 'message: convertToF(0)
should return a value of 32
');",
+ "assert(convertToF(20) === 68, 'message: convertToF(20)
should return a value of 68
');",
+ "assert(convertToF(30) === 86, 'message: convertToF(30)
should return a value of 86
');"
],
"type": "checkpoint",
"challengeType": 1,
@@ -2027,15 +2027,15 @@
"functionName();
",
"Each time the function is called it will print out the message \"Hello World\"
on the dev console. All of the code between the curly braces will be executed every time the function is called.",
"
myFunction
which prints \"Hi World\"
to the dev console.reusableFunction
which prints \"Hi World\"
to the dev console.myFunction
should be a function');",
- "assert(\"Hi World\" === logOutput, 'message: myFunction
should output \"Hi World\" to the dev console');",
- "assert(/^\\s*myFunction\\(\\)\\s*;/m.test(code), 'message: Call myFunction
after you define it');"
+ "assert(typeof reusableFunction === 'function', 'message: reusableFunction
should be a function');",
+ "assert(\"Hi World\" === logOutput, 'message: reusableFunction
should output \"Hi World\" to the dev console');",
+ "assert(/^\\s*reusableFunction\\(\\)\\s*;/m.test(code), 'message: Call reusableFunction
after you define it');"
],
"type": "waypoint",
"challengeType": 1,
@@ -2104,7 +2104,7 @@
"testFun(\"Hello\", \"World\");
",
"We have passed two arguments, \"Hello\"
and \"World\"
. Inside the function, param1
will equal \"Hello\" and param2
will equal \"World\". Note that you could call testFun
again with different arguments and the parameters would take on the value of the new arguments.",
"myFunction
that accepts two arguments and outputs their sum to the dev console.functionWithArgs
that accepts two arguments and outputs their sum to the dev console.myFunction
should be a function');",
- "if(typeof myFunction === \"function\") { capture(); myFunction(1,2); uncapture(); } assert(logOutput == 3, 'message: myFunction(1,2)
should output 3
');",
- "if(typeof myFunction === \"function\") { capture(); myFunction(7,9); uncapture(); } assert(logOutput == 16, 'message: myFunction(7,9)
should output 16
');",
- "assert(/^\\s*myFunction\\s*\\([\\w\\W]+\\)\\s*;/m.test(code), 'message: Call myFunction
after you define it.');"
+ "assert(typeof functionWithArgs === 'function', 'message: functionWithArgs
should be a function');",
+ "if(typeof functionWithArgs === \"function\") { capture(); functionWithArgs(1,2); uncapture(); } assert(logOutput == 3, 'message: functionWithArgs(1,2)
should output 3
');",
+ "if(typeof functionWithArgs === \"function\") { capture(); functionWithArgs(7,9); uncapture(); } assert(logOutput == 16, 'message: functionWithArgs(7,9)
should output 16
');",
+ "assert(/^\\s*functionWithArgs\\s*\\([\\w\\W]+\\)\\s*;/m.test(code), 'message: Call functionWithArgs
after you define it.');"
],
"type": "waypoint",
"challengeType": 1,
@@ -2169,7 +2169,7 @@
"testFun(\"Hello\", \"World\");
",
"Nosotros hemos pasado dos argumentos, \"Hello\"
y \"World\"
. Dentro de la función, param1
será igual a \"Hello\" y param2
será igual a \"World\". Nota que puedes llamar testFun
otra vez con argumentos diferentes y los parámetros asumirían el valor de los nuevos argumentos.",
"myFunction
que acepte dos argumentos y da salida a su suma en la consola.functionWithArgs
que acepte dos argumentos y da salida a su suma en la consola.function myTest() {", "
var loc = \"foo\";
console.log(loc);
}
myTest(); // \"foo\"
console.log(loc); // \"undefined\"
loc
is not defined outside of the function.",
"myVar
inside myFunction
. Run the tests and then follow the instructions commented out in the editor.",
+ "Declare a local variable myVar
inside myLocalScope
. Run the tests and then follow the instructions commented out in the editor.",
"HintmyVar
variable');",
@@ -2323,7 +2323,7 @@
"function myTest() {", "
var loc = \"foo\";
console.log(loc);
}
myTest(); // \"foo\"
console.log(loc); // \"undefined\"
loc
no está definida fuera de la función.",
"myVar
dentro de myFunction
"
+ "Declara una variable local myVar
dentro de myLocalScope
"
]
},
{
@@ -2335,14 +2335,14 @@
"var someVar = \"Hat\";", "The function
function myFun() {
var someVar = \"Head\";
return someVar;
}
myFun
will return \"Head\"
because the local
version of the variable is present.",
"myFunction
to override the value of outerWear
with \"sweater\"
."
+ "Add a local variable to myOutfit
to override the value of outerWear
with \"sweater\"
."
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
"// Setup",
"var outerWear = \"T-Shirt\";",
"",
- "function myFunction() {",
+ "function myOutfit() {",
" // Only change code below this line",
" ",
" ",
@@ -2351,14 +2351,14 @@
" return outerWear;",
"}",
"",
- "myFunction();"
+ "myOutfit();"
],
"solutions": [
- "var outerWear = \"T-Shirt\";\nfunction myFunction() {\n var outerWear = \"sweater\";\n return outerWear;\n}"
+ "var outerWear = \"T-Shirt\";\nfunction myOutfit() {\n var outerWear = \"sweater\";\n return outerWear;\n}"
],
"tests": [
"assert(outerWear === \"T-Shirt\", 'message: Do not change the value of the global outerWear
');",
- "assert(myFunction() === \"sweater\", 'message: myFunction
should return \"sweater\"
');",
+ "assert(myOutfit() === \"sweater\", 'message: myOutfit
should return \"sweater\"
');",
"assert(/return outerWear/.test(code), 'message: Do not change the return statement');"
],
"type": "waypoint",
@@ -2370,7 +2370,7 @@
"var algunaVar = \"Sombrero\";", "La función
function miFun() {
var algunaVar = \"Cabeza\";
return algunaVar;
}
miFun
regresará \"Cabeza\"
porque la versión local
de la variable tiene precedencia.",
"myFunction
para sobreescribir el valor de outerWear
con \"sweater\"
."
+ "Agrega una variable local a myOutfit
para sobreescribir el valor de outerWear
con \"sweater\"
."
]
},
{
@@ -2428,7 +2428,7 @@
"ourSum = sum(5, 12);
",
"will call sum
function, which returns a value of 17
and assigns it to ourSum
variable.",
"process
function with an argument of 7
and assign its return value to the variable processed
."
+ "Call the processArg
function with an argument of 7
and assign its return value to the variable processed
."
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
@@ -2444,7 +2444,7 @@
"// Setup",
"var processed = 0;",
"",
- "function process(num) {",
+ "function processArg(num) {",
" return (num + 3) / 5;",
"}",
"",
@@ -2456,11 +2456,11 @@
"(function(){return \"processed = \" + processed})();"
],
"solutions": [
- "var processed = 0;\n\nfunction process(num) {\n return (num + 3) / 5;\n}\n\nprocessed = process(7);"
+ "var processed = 0;\n\nfunction processArg(num) {\n return (num + 3) / 5;\n}\n\nprocessed = processArg(7);"
],
"tests": [
"assert(processed === 2, 'message: processed
should have a value of 2
');",
- "assert(/processed\\s*=\\s*process\\(\\s*7\\s*\\)\\s*;/.test(code), 'message: You should assign process
to processed
');"
+ "assert(/processed\\s*=\\s*processArg\\(\\s*7\\s*\\)\\s*;/.test(code), 'message: You should assign processArg
to processed
');"
],
"type": "waypoint",
"challengeType": 1,
@@ -2471,7 +2471,7 @@
"nuestraSuma = suma(5, 12);
",
"llamará la función suma
, la cual retornará un valor de 17
y lo asignará a la variable nuestraSuma
.",
"process
con un argumento 7
y asigna su valor de retorno a la variable processed
."
+ "Llama la función processArg
con un argumento 7
y asigna su valor de retorno a la variable processed
."
]
},
{
@@ -2479,7 +2479,7 @@
"title": "Stand in Line",
"description": [
"In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue
and old items are taken off from the front of the queue
.",
- "Write a function queue
which takes an array (arr
) and a number (item
) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed."
+ "Write a function nextInLine
which takes an array (arr
) and a number (item
) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed."
],
"releasedOn": "January 1, 2016",
"head": [
@@ -2505,7 +2505,7 @@
"capture();"
],
"challengeSeed": [
- "function queue(arr, item) {",
+ "function nextInLine(arr, item) {",
" // Your code here",
" ",
" return item; // Change this line",
@@ -2516,7 +2516,7 @@
"",
"// Display Code",
"console.log(\"Before: \" + JSON.stringify(testArr));",
- "console.log(queue(testArr, 6)); // Modify this line to test",
+ "console.log(nextInLine(testArr, 6)); // Modify this line to test",
"console.log(\"After: \" + JSON.stringify(testArr));"
],
"tail": [
@@ -2525,20 +2525,20 @@
"(function() { return logOutput.join(\"\\n\");})();"
],
"solutions": [
- "var testArr = [ 1,2,3,4,5];\n\nfunction queue(arr, item) {\n arr.push(item);\n return arr.shift();\n}"
+ "var testArr = [ 1,2,3,4,5];\n\nfunction nextInLine(arr, item) {\n arr.push(item);\n return arr.shift();\n}"
],
"tests": [
- "assert(queue([],1) === 1, 'message: queue([], 1)
should return 1
');",
- "assert(queue([2],1) === 2, 'message: queue([2], 1)
should return 2
');",
- "assert(queue([5,6,7,8,9],1) === 5, 'message: queue([5,6,7,8,9], 1)
should return 5
');",
- "queue(testArr, 10); assert(testArr[4] === 10, 'message: After queue(testArr, 10)
, testArr[4]
should be 10
');"
+ "assert(nextInLine([],1) === 1, 'message: nextInLine([], 1)
should return 1
');",
+ "assert(nextInLine([2],1) === 2, 'message: nextInLine([2], 1)
should return 2
');",
+ "assert(nextInLine([5,6,7,8,9],1) === 5, 'message: nextInLine([5,6,7,8,9], 1)
should return 5
');",
+ "nextInLine(testArr, 10); assert(testArr[4] === 10, 'message: After nextInLine(testArr, 10)
, testArr[4]
should be 10
');"
],
"type": "checkpoint",
"challengeType": 1,
"titleEs": "Hacer cola",
"descriptionEs": [
"En Ciencias de la Computación una cola es una Estructura de Datos abstracta donde los elementos son mantenidos en orden. Nuevos elementos pueden ser agregados en la parte trasera de la cola
y los elementos viejos son quitados desde el frente de la cola
.",
- "Escribe una función queue
la cual toma un vector (arr
) y un número (item
) como argumentos. Agrega el número al final del vector, entonces retira el primer elemento del vector. La función queue debe entonces devolver el elemento que se ha eliminado."
+ "Escribe una función nextInLine
la cual toma un vector (arr
) y un número (item
) como argumentos. Agrega el número al final del vector, entonces retira el primer elemento del vector. La función nextInLine debe entonces devolver el elemento que se ha eliminado."
]
},
{
@@ -2604,7 +2604,7 @@
"}",
"",
"// Setup",
- "function myFunction(wasThatTrue) {",
+ "function trueOrFalse(wasThatTrue) {",
"",
" // Only change code below this line.",
" ",
@@ -2615,17 +2615,17 @@
"}",
"",
"// Change this value to test",
- "myFunction(true);"
+ "trueOrFalse(true);"
],
"solutions": [
- "function myFunction(wasThatTrue) {\n if (wasThatTrue) {\n return \"That was true\";\n }\n return \"That was false\";\n}"
+ "function trueOrFalse(wasThatTrue) {\n if (wasThatTrue) {\n return \"That was true\";\n }\n return \"That was false\";\n}"
],
"tests": [
- "assert(typeof myFunction === \"function\", 'message: myFunction
should be a function');",
- "assert(typeof myFunction(true) === \"string\", 'message: myFunction(true)
should return a string');",
- "assert(typeof myFunction(false) === \"string\", 'message: myFunction(false)
should return a string');",
- "assert(myFunction(true) === \"That was true\", 'message: myFunction(true)
should return \"That was true\"');",
- "assert(myFunction(false) === \"That was false\", 'message: myFunction(false)
should return \"That was false\"');"
+ "assert(typeof trueOrFalse === \"function\", 'message: trueOrFalse
should be a function');",
+ "assert(typeof trueOrFalse(true) === \"string\", 'message: trueOrFalse(true)
should return a string');",
+ "assert(typeof trueOrFalse(false) === \"string\", 'message: trueOrFalse(false)
should return a string');",
+ "assert(trueOrFalse(true) === \"That was true\", 'message: trueOrFalse(true)
should return \"That was true\"');",
+ "assert(trueOrFalse(false) === \"That was false\", 'message: trueOrFalse(false)
should return \"That was false\"');"
],
"type": "waypoint",
"challengeType": 1,
@@ -2660,7 +2660,7 @@
"releasedOn": "January 1, 2016",
"challengeSeed": [
"// Setup",
- "function myTest(val) {",
+ "function testEqual(val) {",
" if (val) { // Change this line",
" return \"Equal\";",
" }",
@@ -2668,15 +2668,15 @@
"}",
"",
"// Change this value to test",
- "myTest(10);"
+ "testEqual(10);"
],
"solutions": [
- "function myTest(val) {\n if (val == 12) {\n return \"Equal\";\n }\n return \"Not Equal\";\n}"
+ "function testEqual(val) {\n if (val == 12) {\n return \"Equal\";\n }\n return \"Not Equal\";\n}"
],
"tests": [
- "assert(myTest(10) === \"Not Equal\", 'message: myTest(10)
should return \"Not Equal\"');",
- "assert(myTest(12) === \"Equal\", 'message: myTest(12)
should return \"Equal\"');",
- "assert(myTest(\"12\") === \"Equal\", 'message: myTest(\"12\")
should return \"Equal\"');",
+ "assert(testEqual(10) === \"Not Equal\", 'message: testEqual(10)
should return \"Not Equal\"');",
+ "assert(testEqual(12) === \"Equal\", 'message: testEqual(12)
should return \"Equal\"');",
+ "assert(testEqual(\"12\") === \"Equal\", 'message: testEqual(\"12\")
should return \"Equal\"');",
"assert(code.match(/val\\s*==[\\s'\"\\d]+/g).length > 0, 'message: You should use the ==
operator');"
],
"type": "waypoint",
@@ -2707,7 +2707,7 @@
"releasedOn": "January 1, 2016",
"challengeSeed": [
"// Setup",
- "function myTest(val) {",
+ "function testStrict(val) {",
" if (val) { // Change this line",
" return \"Equal\";",
" }",
@@ -2715,15 +2715,15 @@
"}",
"",
"// Change this value to test",
- "myTest(10);"
+ "testStrict(10);"
],
"solutions": [
- "function myTest(val) {\n if (val === 7) {\n return \"Equal\";\n }\n return \"Not Equal\";\n}"
+ "function testStrict(val) {\n if (val === 7) {\n return \"Equal\";\n }\n return \"Not Equal\";\n}"
],
"tests": [
- "assert(myTest(10) === \"Not Equal\", 'message: myTest(10)
should return \"Not Equal\"');",
- "assert(myTest(7) === \"Equal\", 'message: myTest(7)
should return \"Equal\"');",
- "assert(myTest(\"7\") === \"Not Equal\", 'message: myTest(\"7\")
should return \"Not Equal\"');",
+ "assert(testStrict(10) === \"Not Equal\", 'message: testStrict(10)
should return \"Not Equal\"');",
+ "assert(testStrict(7) === \"Equal\", 'message: testStrict(7)
should return \"Equal\"');",
+ "assert(testStrict(\"7\") === \"Not Equal\", 'message: testStrict(\"7\")
should return \"Not Equal\"');",
"assert(code.match(/val\\s*===\\s*\\d+/g).length > 0, 'message: You should use the ===
operator');"
],
"type": "waypoint",
@@ -2751,7 +2751,7 @@
"releasedOn": "January 1, 2016",
"challengeSeed": [
"// Setup",
- "function myTest(val) {",
+ "function testNotEqual(val) {",
" if (val) { // Change this line",
" return \"Not Equal\";",
" }",
@@ -2759,17 +2759,17 @@
"}",
"",
"// Change this value to test",
- "myTest(10);"
+ "testNotEqual(10);"
],
"solutions": [
- "function myTest(val) {\n if (val != 99) {\n return \"Not Equal\";\n }\n return \"Equal\";\n}"
+ "function testNotEqual(val) {\n if (val != 99) {\n return \"Not Equal\";\n }\n return \"Equal\";\n}"
],
"tests": [
- "assert(myTest(99) === \"Equal\", 'message: myTest(99)
should return \"Equal\"');",
- "assert(myTest(\"99\") === \"Equal\", 'message: myTest(\"99\")
should return \"Equal\"');",
- "assert(myTest(12) === \"Not Equal\", 'message: myTest(12)
should return \"Not Equal\"');",
- "assert(myTest(\"12\") === \"Not Equal\", 'message: myTest(\"12\")
should return \"Not Equal\"');",
- "assert(myTest(\"bob\") === \"Not Equal\", 'message: myTest(\"bob\")
should return \"Not Equal\"');",
+ "assert(testNotEqual(99) === \"Equal\", 'message: testNotEqual(99)
should return \"Equal\"');",
+ "assert(testNotEqual(\"99\") === \"Equal\", 'message: testNotEqual(\"99\")
should return \"Equal\"');",
+ "assert(testNotEqual(12) === \"Not Equal\", 'message: testNotEqual(12)
should return \"Not Equal\"');",
+ "assert(testNotEqual(\"12\") === \"Not Equal\", 'message: testNotEqual(\"12\")
should return \"Not Equal\"');",
+ "assert(testNotEqual(\"bob\") === \"Not Equal\", 'message: testNotEqual(\"bob\")
should return \"Not Equal\"');",
"assert(code.match(/val\\s*!=\\s*\\d+/g).length > 0, 'message: You should use the !=
operator');"
],
"type": "waypoint",
@@ -2796,7 +2796,7 @@
"releasedOn": "January 1, 2016",
"challengeSeed": [
"// Setup",
- "function myTest(val) {",
+ "function testStrictNotEqual(val) {",
" // Only Change Code Below this Line",
" ",
" if (val) {",
@@ -2809,16 +2809,16 @@
"}",
"",
"// Change this value to test",
- "myTest(10);"
+ "testStrictNotEqual(10);"
],
"solutions": [
- "function myTest(val) {\n if (val !== 17) {\n return \"Not Equal\";\n }\n return \"Equal\";\n}"
+ "function testStrictNotEqual(val) {\n if (val !== 17) {\n return \"Not Equal\";\n }\n return \"Equal\";\n}"
],
"tests": [
- "assert(myTest(17) === \"Equal\", 'message: myTest(17)
should return \"Equal\"');",
- "assert(myTest(\"17\") === \"Not Equal\", 'message: myTest(\"17\")
should return \"Not Equal\"');",
- "assert(myTest(12) === \"Not Equal\", 'message: myTest(12)
should return \"Not Equal\"');",
- "assert(myTest(\"bob\") === \"Not Equal\", 'message: myTest(\"bob\")
should return \"Not Equal\"');",
+ "assert(testStrictNotEqual(17) === \"Equal\", 'message: testStrictNotEqual(17)
should return \"Equal\"');",
+ "assert(testStrictNotEqual(\"17\") === \"Not Equal\", 'message: testStrictNotEqual(\"17\")
should return \"Not Equal\"');",
+ "assert(testStrictNotEqual(12) === \"Not Equal\", 'message: testStrictNotEqual(12)
should return \"Not Equal\"');",
+ "assert(testStrictNotEqual(\"bob\") === \"Not Equal\", 'message: testStrictNotEqual(\"bob\")
should return \"Not Equal\"');",
"assert(code.match(/val\\s*!==\\s*\\d+/g).length > 0, 'message: You should use the !==
operator');"
],
"type": "waypoint",
@@ -2845,7 +2845,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function testGreaterThan(val) {",
" if (val) { // Change this line",
" return \"Over 100\";",
" }",
@@ -2858,19 +2858,19 @@
"}",
"",
"// Change this value to test",
- "myTest(10);"
+ "testGreaterThan(10);"
],
"solutions": [
- "function myTest(val) {\n if (val > 100) { // Change this line\n return \"Over 100\";\n }\n if (val > 10) { // Change this line\n return \"Over 10\";\n }\n return \"10 or Under\";\n}"
+ "function testGreaterThan(val) {\n if (val > 100) { // Change this line\n return \"Over 100\";\n }\n if (val > 10) { // Change this line\n return \"Over 10\";\n }\n return \"10 or Under\";\n}"
],
"tests": [
- "assert(myTest(0) === \"10 or Under\", 'message: myTest(0)
should return \"10 or Under\"');",
- "assert(myTest(10) === \"10 or Under\", 'message: myTest(10)
should return \"10 or Under\"');",
- "assert(myTest(11) === \"Over 10\", 'message: myTest(11)
should return \"Over 10\"');",
- "assert(myTest(99) === \"Over 10\", 'message: myTest(99)
should return \"Over 10\"');",
- "assert(myTest(100) === \"Over 10\", 'message: myTest(100)
should return \"Over 10\"');",
- "assert(myTest(101) === \"Over 100\", 'message: myTest(101)
should return \"Over 100\"');",
- "assert(myTest(150) === \"Over 100\", 'message: myTest(150)
should return \"Over 100\"');",
+ "assert(testGreaterThan(0) === \"10 or Under\", 'message: testGreaterThan(0)
should return \"10 or Under\"');",
+ "assert(testGreaterThan(10) === \"10 or Under\", 'message: testGreaterThan(10)
should return \"10 or Under\"');",
+ "assert(testGreaterThan(11) === \"Over 10\", 'message: testGreaterThan(11)
should return \"Over 10\"');",
+ "assert(testGreaterThan(99) === \"Over 10\", 'message: testGreaterThan(99)
should return \"Over 10\"');",
+ "assert(testGreaterThan(100) === \"Over 10\", 'message: testGreaterThan(100)
should return \"Over 10\"');",
+ "assert(testGreaterThan(101) === \"Over 100\", 'message: testGreaterThan(101)
should return \"Over 100\"');",
+ "assert(testGreaterThan(150) === \"Over 100\", 'message: testGreaterThan(150)
should return \"Over 100\"');",
"assert(code.match(/val\\s*>\\s*('|\")*\\d+('|\")*/g).length > 1, 'message: You should use the >
operator at least twice');"
],
"type": "waypoint",
@@ -2898,7 +2898,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function testGreaterOrEqual(val) {",
" if (val) { // Change this line",
" return \"20 or Over\";",
" }",
@@ -2911,19 +2911,19 @@
"}",
"",
"// Change this value to test",
- "myTest(10);"
+ "testGreaterOrEqual(10);"
],
"solutions": [
- "function myTest(val) {\n if (val >= 20) { // Change this line\n return \"20 or Over\";\n }\n \n if (val >= 10) { // Change this line\n return \"10 or Over\";\n }\n\n return \"9 or Under\";\n}"
+ "function testGreaterOrEqual(val) {\n if (val >= 20) { // Change this line\n return \"20 or Over\";\n }\n \n if (val >= 10) { // Change this line\n return \"10 or Over\";\n }\n\n return \"9 or Under\";\n}"
],
"tests": [
- "assert(myTest(0) === \"9 or Under\", 'message: myTest(0)
should return \"9 or Under\"');",
- "assert(myTest(9) === \"9 or Under\", 'message: myTest(9)
should return \"9 or Under\"');",
- "assert(myTest(10) === \"10 or Over\", 'message: myTest(10)
should return \"10 or Over\"');",
- "assert(myTest(11) === \"10 or Over\", 'message: myTest(11)
should return \"10 or Over\"');",
- "assert(myTest(19) === \"10 or Over\", 'message: myTest(19)
should return \"10 or Over\"');",
- "assert(myTest(100) === \"20 or Over\", 'message: myTest(100)
should return \"20 or Over\"');",
- "assert(myTest(21) === \"20 or Over\", 'message: myTest(21)
should return \"20 or Over\"');",
+ "assert(testGreaterOrEqual(0) === \"9 or Under\", 'message: testGreaterOrEqual(0)
should return \"9 or Under\"');",
+ "assert(testGreaterOrEqual(9) === \"9 or Under\", 'message: testGreaterOrEqual(9)
should return \"9 or Under\"');",
+ "assert(testGreaterOrEqual(10) === \"10 or Over\", 'message: testGreaterOrEqual(10)
should return \"10 or Over\"');",
+ "assert(testGreaterOrEqual(11) === \"10 or Over\", 'message: testGreaterOrEqual(11)
should return \"10 or Over\"');",
+ "assert(testGreaterOrEqual(19) === \"10 or Over\", 'message: testGreaterOrEqual(19)
should return \"10 or Over\"');",
+ "assert(testGreaterOrEqual(100) === \"20 or Over\", 'message: testGreaterOrEqual(100)
should return \"20 or Over\"');",
+ "assert(testGreaterOrEqual(21) === \"20 or Over\", 'message: testGreaterOrEqual(21)
should return \"20 or Over\"');",
"assert(code.match(/val\\s*>=\\s*('|\")*\\d+('|\")*/g).length > 1, 'message: You should use the >=
operator at least twice');"
],
"type": "waypoint",
@@ -2950,7 +2950,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function testLessThan(val) {",
" if (val) { // Change this line",
" return \"Under 25\";",
" }",
@@ -2963,18 +2963,18 @@
"}",
"",
"// Change this value to test",
- "myTest(10);"
+ "testLessThan(10);"
],
"solutions": [
- "function myTest(val) {\n if (val < 25) { // Change this line\n return \"Under 25\";\n }\n \n if (val < 55) { // Change this line\n return \"Under 55\";\n }\n\n return \"55 or Over\";\n}"
+ "function testLessThan(val) {\n if (val < 25) { // Change this line\n return \"Under 25\";\n }\n \n if (val < 55) { // Change this line\n return \"Under 55\";\n }\n\n return \"55 or Over\";\n}"
],
"tests": [
- "assert(myTest(0) === \"Under 25\", 'message: myTest(0)
should return \"Under 25\"');",
- "assert(myTest(24) === \"Under 25\", 'message: myTest(24)
should return \"Under 25\"');",
- "assert(myTest(25) === \"Under 55\", 'message: myTest(25)
should return \"Under 55\"');",
- "assert(myTest(54) === \"Under 55\", 'message: myTest(54)
should return \"Under 55\"');",
- "assert(myTest(55) === \"55 or Over\", 'message: myTest(55)
should return \"55 or Over\"');",
- "assert(myTest(99) === \"55 or Over\", 'message: myTest(99)
should return \"55 or Over\"');",
+ "assert(testLessThan(0) === \"Under 25\", 'message: testLessThan(0)
should return \"Under 25\"');",
+ "assert(testLessThan(24) === \"Under 25\", 'message: testLessThan(24)
should return \"Under 25\"');",
+ "assert(testLessThan(25) === \"Under 55\", 'message: testLessThan(25)
should return \"Under 55\"');",
+ "assert(testLessThan(54) === \"Under 55\", 'message: testLessThan(54)
should return \"Under 55\"');",
+ "assert(testLessThan(55) === \"55 or Over\", 'message: testLessThan(55)
should return \"55 or Over\"');",
+ "assert(testLessThan(99) === \"55 or Over\", 'message: testLessThan(99)
should return \"55 or Over\"');",
"assert(code.match(/val\\s*<\\s*('|\")*\\d+('|\")*/g).length > 1, 'message: You should use the <
operator at least twice');"
],
"type": "waypoint",
@@ -3000,7 +3000,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function testLessOrEqual(val) {",
" if (val) { // Change this line",
" return \"Smaller Than or Equal to 12\";",
" }",
@@ -3013,20 +3013,20 @@
"}",
"",
"// Change this value to test",
- "myTest(10);",
+ "testLessOrEqual(10);",
""
],
"solutions": [
- "function myTest(val) {\n if (val <= 12) { // Change this line\n return \"Smaller Than or Equal to 12\";\n }\n \n if (val <= 24) { // Change this line\n return \"Smaller Than or Equal to 24\";\n }\n\n return \"25 or More\";\n}"
+ "function testLessOrEqual(val) {\n if (val <= 12) { // Change this line\n return \"Smaller Than or Equal to 12\";\n }\n \n if (val <= 24) { // Change this line\n return \"Smaller Than or Equal to 24\";\n }\n\n return \"25 or More\";\n}"
],
"tests": [
- "assert(myTest(0) === \"Smaller Than or Equal to 12\", 'message: myTest(0)
should return \"Smaller Than or Equal to 12\"');",
- "assert(myTest(11) === \"Smaller Than or Equal to 12\", 'message: myTest(11)
should return \"Smaller Than or Equal to 12\"');",
- "assert(myTest(12) === \"Smaller Than or Equal to 12\", 'message: myTest(12)
should return \"Smaller Than or Equal to 12\"');",
- "assert(myTest(23) === \"Smaller Than or Equal to 24\", 'message: myTest(23)
should return \"Smaller Than or Equal to 24\"');",
- "assert(myTest(24) === \"Smaller Than or Equal to 24\", 'message: myTest(24)
should return \"Smaller Than or Equal to 24\"');",
- "assert(myTest(25) === \"25 or More\", 'message: myTest(25)
should return \"25 or More\"');",
- "assert(myTest(55) === \"25 or More\", 'message: myTest(55)
should return \"25 or More\"');",
+ "assert(testLessOrEqual(0) === \"Smaller Than or Equal to 12\", 'message: testLessOrEqual(0)
should return \"Smaller Than or Equal to 12\"');",
+ "assert(testLessOrEqual(11) === \"Smaller Than or Equal to 12\", 'message: testLessOrEqual(11)
should return \"Smaller Than or Equal to 12\"');",
+ "assert(testLessOrEqual(12) === \"Smaller Than or Equal to 12\", 'message: testLessOrEqual(12)
should return \"Smaller Than or Equal to 12\"');",
+ "assert(testLessOrEqual(23) === \"Smaller Than or Equal to 24\", 'message: testLessOrEqual(23)
should return \"Smaller Than or Equal to 24\"');",
+ "assert(testLessOrEqual(24) === \"Smaller Than or Equal to 24\", 'message: testLessOrEqual(24)
should return \"Smaller Than or Equal to 24\"');",
+ "assert(testLessOrEqual(25) === \"25 or More\", 'message: testLessOrEqual(25)
should return \"25 or More\"');",
+ "assert(testLessOrEqual(55) === \"25 or More\", 'message: testLessOrEqual(55)
should return \"25 or More\"');",
"assert(code.match(/val\\s*<=\\s*('|\")*\\d+('|\")*/g).length > 1, 'message: You should use the <=
operator at least twice');"
],
"type": "waypoint",
@@ -3054,7 +3054,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function testLogicalAnd(val) {",
" // Only change code below this line",
"",
" if (val) {",
@@ -3068,22 +3068,22 @@
"}",
"",
"// Change this value to test",
- "myTest(10);"
+ "testLogicalAnd(10);"
],
"solutions": [
- "function myTest(val) {\n if (val >= 25 && val <= 50) {\n return \"Yes\";\n }\n return \"No\";\n}"
+ "function testLogicalAnd(val) {\n if (val >= 25 && val <= 50) {\n return \"Yes\";\n }\n return \"No\";\n}"
],
"tests": [
"assert(code.match(/&&/g).length === 1, 'message: You should use the &&
operator once');",
"assert(code.match(/if/g).length === 1, 'message: You should only have one if
statement');",
- "assert(myTest(0) === \"No\", 'message: myTest(0)
should return \"No\"');",
- "assert(myTest(24) === \"No\", 'message: myTest(24)
should return \"No\"');",
- "assert(myTest(25) === \"Yes\", 'message: myTest(25)
should return \"Yes\"');",
- "assert(myTest(30) === \"Yes\", 'message: myTest(30)
should return \"Yes\"');",
- "assert(myTest(50) === \"Yes\", 'message: myTest(50)
should return \"Yes\"');",
- "assert(myTest(51) === \"No\", 'message: myTest(51)
should return \"No\"');",
- "assert(myTest(75) === \"No\", 'message: myTest(75)
should return \"No\"');",
- "assert(myTest(80) === \"No\", 'message: myTest(80)
should return \"No\"');"
+ "assert(testLogicalAnd(0) === \"No\", 'message: testLogicalAnd(0)
should return \"No\"');",
+ "assert(testLogicalAnd(24) === \"No\", 'message: testLogicalAnd(24)
should return \"No\"');",
+ "assert(testLogicalAnd(25) === \"Yes\", 'message: testLogicalAnd(25)
should return \"Yes\"');",
+ "assert(testLogicalAnd(30) === \"Yes\", 'message: testLogicalAnd(30)
should return \"Yes\"');",
+ "assert(testLogicalAnd(50) === \"Yes\", 'message: testLogicalAnd(50)
should return \"Yes\"');",
+ "assert(testLogicalAnd(51) === \"No\", 'message: testLogicalAnd(51)
should return \"No\"');",
+ "assert(testLogicalAnd(75) === \"No\", 'message: testLogicalAnd(75)
should return \"No\"');",
+ "assert(testLogicalAnd(80) === \"No\", 'message: testLogicalAnd(80)
should return \"No\"');"
],
"type": "waypoint",
"challengeType": 1,
@@ -3112,7 +3112,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function testLogicalOr(val) {",
" // Only change code below this line",
"",
" if (val) {",
@@ -3128,22 +3128,22 @@
"}",
"",
"// Change this value to test",
- "myTest(15);"
+ "testLogicalOr(15);"
],
"solutions": [
- "function myTest(val) {\n if (val < 10 || val > 20) {\n return \"Outside\";\n }\n return \"Inside\";\n}"
+ "function testLogicalOr(val) {\n if (val < 10 || val > 20) {\n return \"Outside\";\n }\n return \"Inside\";\n}"
],
"tests": [
"assert(code.match(/\\|\\|/g).length === 1, 'message: You should use the ||
operator once');",
"assert(code.match(/if/g).length === 1, 'message: You should only have one if
statement');",
- "assert(myTest(0) === \"Outside\", 'message: myTest(0)
should return \"Outside\"');",
- "assert(myTest(9) === \"Outside\", 'message: myTest(9)
should return \"Outside\"');",
- "assert(myTest(10) === \"Inside\", 'message: myTest(10)
should return \"Inside\"');",
- "assert(myTest(15) === \"Inside\", 'message: myTest(15)
should return \"Inside\"');",
- "assert(myTest(19) === \"Inside\", 'message: myTest(19)
should return \"Inside\"');",
- "assert(myTest(20) === \"Inside\", 'message: myTest(20)
should return \"Inside\"');",
- "assert(myTest(21) === \"Outside\", 'message: myTest(21)
should return \"Outside\"');",
- "assert(myTest(25) === \"Outside\", 'message: myTest(25)
should return \"Outside\"');"
+ "assert(testLogicalOr(0) === \"Outside\", 'message: testLogicalOr(0)
should return \"Outside\"');",
+ "assert(testLogicalOr(9) === \"Outside\", 'message: testLogicalOr(9)
should return \"Outside\"');",
+ "assert(testLogicalOr(10) === \"Inside\", 'message: testLogicalOr(10)
should return \"Inside\"');",
+ "assert(testLogicalOr(15) === \"Inside\", 'message: testLogicalOr(15)
should return \"Inside\"');",
+ "assert(testLogicalOr(19) === \"Inside\", 'message: testLogicalOr(19)
should return \"Inside\"');",
+ "assert(testLogicalOr(20) === \"Inside\", 'message: testLogicalOr(20)
should return \"Inside\"');",
+ "assert(testLogicalOr(21) === \"Outside\", 'message: testLogicalOr(21)
should return \"Outside\"');",
+ "assert(testLogicalOr(25) === \"Outside\", 'message: testLogicalOr(25)
should return \"Outside\"');"
],
"type": "waypoint",
"challengeType": 1,
@@ -3169,7 +3169,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function testElse(val) {",
" var result = \"\";",
" // Only change code below this line",
" ",
@@ -3186,19 +3186,19 @@
"}",
"",
"// Change this value to test",
- "myTest(4);",
+ "testElse(4);",
""
],
"solutions": [
- "function myTest(val) {\n var result = \"\";\n if(val > 5) {\n result = \"Bigger than 5\";\n } else {\n result = \"5 or Smaller\";\n }\n return result;\n}"
+ "function testElse(val) {\n var result = \"\";\n if(val > 5) {\n result = \"Bigger than 5\";\n } else {\n result = \"5 or Smaller\";\n }\n return result;\n}"
],
"tests": [
"assert(code.match(/if/g).length === 1, 'message: You should only have one if
statement');",
"assert(/else/g.test(code), 'message: You should use an else
statement');",
- "assert(myTest(4) === \"5 or Smaller\", 'message: myTest(4)
should return \"5 or Smaller\"');",
- "assert(myTest(5) === \"5 or Smaller\", 'message: myTest(5)
should return \"5 or Smaller\"');",
- "assert(myTest(6) === \"Bigger than 5\", 'message: myTest(6)
should return \"Bigger than 5\"');",
- "assert(myTest(10) === \"Bigger than 5\", 'message: myTest(10)
should return \"Bigger than 5\"');",
+ "assert(testElse(4) === \"5 or Smaller\", 'message: testElse(4)
should return \"5 or Smaller\"');",
+ "assert(testElse(5) === \"5 or Smaller\", 'message: testElse(5)
should return \"5 or Smaller\"');",
+ "assert(testElse(6) === \"Bigger than 5\", 'message: testElse(6)
should return \"Bigger than 5\"');",
+ "assert(testElse(10) === \"Bigger than 5\", 'message: testElse(10)
should return \"Bigger than 5\"');",
"assert(/var result = \"\";/.test(code) && /return result;/.test(code), 'message: Do not change the code above or below the lines.');"
],
"type": "waypoint",
@@ -3222,7 +3222,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function testElseIf(val) {",
" if (val > 10) {",
" return \"Greater than 10\";",
" }",
@@ -3235,20 +3235,20 @@
"}",
"",
"// Change this value to test",
- "myTest(7);",
+ "testElseIf(7);",
""
],
"solutions": [
- "function myTest(val) {\n if(val > 10) {\n return \"Greater than 10\";\n } else if(val < 5) {\n return \"Smaller than 5\";\n } else {\n return \"Between 5 and 10\";\n }\n}"
+ "function testElseIf(val) {\n if(val > 10) {\n return \"Greater than 10\";\n } else if(val < 5) {\n return \"Smaller than 5\";\n } else {\n return \"Between 5 and 10\";\n }\n}"
],
"tests": [
"assert(code.match(/else/g).length > 1, 'message: You should have at least two else
statements');",
"assert(code.match(/if/g).length > 1, 'message: You should have at least two if
statements');",
- "assert(myTest(0) === \"Smaller than 5\", 'message: myTest(0)
should return \"Smaller than 5\"');",
- "assert(myTest(5) === \"Between 5 and 10\", 'message: myTest(5)
should return \"Between 5 and 10\"');",
- "assert(myTest(7) === \"Between 5 and 10\", 'message: myTest(7)
should return \"Between 5 and 10\"');",
- "assert(myTest(10) === \"Between 5 and 10\", 'message: myTest(10)
should return \"Between 5 and 10\"');",
- "assert(myTest(12) === \"Greater than 10\", 'message: myTest(12)
should return \"Greater than 10\"');"
+ "assert(testElseIf(0) === \"Smaller than 5\", 'message: testElseIf(0)
should return \"Smaller than 5\"');",
+ "assert(testElseIf(5) === \"Between 5 and 10\", 'message: testElseIf(5)
should return \"Between 5 and 10\"');",
+ "assert(testElseIf(7) === \"Between 5 and 10\", 'message: testElseIf(7)
should return \"Between 5 and 10\"');",
+ "assert(testElseIf(10) === \"Between 5 and 10\", 'message: testElseIf(10)
should return \"Between 5 and 10\"');",
+ "assert(testElseIf(12) === \"Greater than 10\", 'message: testElseIf(12)
should return \"Greater than 10\"');"
],
"type": "waypoint",
"challengeType": 1,
@@ -3277,7 +3277,7 @@
"Change the order of logic in the function so that it will return the correct statements in all cases."
],
"challengeSeed": [
- "function myTest(val) {",
+ "function orderMyLogic(val) {",
" if (val < 10) {",
" return \"Less than 10\";",
" } else if (val < 5) {",
@@ -3288,15 +3288,15 @@
"}",
"",
"// Change this value to test",
- "myTest(7);"
+ "orderMyLogic(7);"
],
"solutions": [
- "function myTest(val) {\n if(val < 5) {\n return \"Less than 5\"; \n } else if (val < 10) {\n return \"Less than 10\";\n } else {\n return \"Greater than or equal to 10\";\n }\n}"
+ "function orderMyLogic(val) {\n if(val < 5) {\n return \"Less than 5\"; \n } else if (val < 10) {\n return \"Less than 10\";\n } else {\n return \"Greater than or equal to 10\";\n }\n}"
],
"tests": [
- "assert(myTest(4) === \"Less than 5\", 'message: myTest(4)
should return \"Less than 5\"');",
- "assert(myTest(6) === \"Less than 10\", 'message: myTest(6)
should return \"Less than 10\"');",
- "assert(myTest(11) === \"Greater than or equal to 10\", 'message: myTest(11)
should return \"Greater than or equal to 10\"');"
+ "assert(orderMyLogic(4) === \"Less than 5\", 'message: orderMyLogic(4)
should return \"Less than 5\"');",
+ "assert(orderMyLogic(6) === \"Less than 10\", 'message: orderMyLogic(6)
should return \"Less than 10\"');",
+ "assert(orderMyLogic(11) === \"Greater than or equal to 10\", 'message: orderMyLogic(11)
should return \"Greater than or equal to 10\"');"
],
"type": "waypoint",
"challengeType": 1,
@@ -3327,7 +3327,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(num) {",
+ "function testSize(num) {",
" // Only change code below this line",
" ",
" ",
@@ -3336,25 +3336,25 @@
"}",
"",
"// Change this value to test",
- "myTest(7);"
+ "testSize(7);"
],
"solutions": [
- "function myTest(num) {\n if (num < 5) {\n return \"Tiny\";\n } else if (num < 10) {\n return \"Small\";\n } else if (num < 15) {\n return \"Medium\";\n } else if (num < 20) {\n return \"Large\";\n } else {\n return \"Huge\";\n }\n}"
+ "function testSize(num) {\n if (num < 5) {\n return \"Tiny\";\n } else if (num < 10) {\n return \"Small\";\n } else if (num < 15) {\n return \"Medium\";\n } else if (num < 20) {\n return \"Large\";\n } else {\n return \"Huge\";\n }\n}"
],
"tests": [
"assert(code.match(/else/g).length > 3, 'message: You should have at least four else
statements');",
"assert(code.match(/if/g).length > 3, 'message: You should have at least four if
statements');",
"assert(code.match(/return/g).length >= 1, 'message: You should have at least one return
statement');",
- "assert(myTest(0) === \"Tiny\", 'message: myTest(0)
should return \"Tiny\"');",
- "assert(myTest(4) === \"Tiny\", 'message: myTest(4)
should return \"Tiny\"');",
- "assert(myTest(5) === \"Small\", 'message: myTest(5)
should return \"Small\"');",
- "assert(myTest(8) === \"Small\", 'message: myTest(8)
should return \"Small\"');",
- "assert(myTest(10) === \"Medium\", 'message: myTest(10)
should return \"Medium\"');",
- "assert(myTest(14) === \"Medium\", 'message: myTest(14)
should return \"Medium\"');",
- "assert(myTest(15) === \"Large\", 'message: myTest(15)
should return \"Large\"');",
- "assert(myTest(17) === \"Large\", 'message: myTest(17)
should return \"Large\"');",
- "assert(myTest(20) === \"Huge\", 'message: myTest(20)
should return \"Huge\"');",
- "assert(myTest(25) === \"Huge\", 'message: myTest(25)
should return \"Huge\"');"
+ "assert(testSize(0) === \"Tiny\", 'message: testSize(0)
should return \"Tiny\"');",
+ "assert(testSize(4) === \"Tiny\", 'message: testSize(4)
should return \"Tiny\"');",
+ "assert(testSize(5) === \"Small\", 'message: testSize(5)
should return \"Small\"');",
+ "assert(testSize(8) === \"Small\", 'message: testSize(8)
should return \"Small\"');",
+ "assert(testSize(10) === \"Medium\", 'message: testSize(10)
should return \"Medium\"');",
+ "assert(testSize(14) === \"Medium\", 'message: testSize(14)
should return \"Medium\"');",
+ "assert(testSize(15) === \"Large\", 'message: testSize(15)
should return \"Large\"');",
+ "assert(testSize(17) === \"Large\", 'message: testSize(17)
should return \"Large\"');",
+ "assert(testSize(20) === \"Huge\", 'message: testSize(20)
should return \"Huge\"');",
+ "assert(testSize(25) === \"Huge\", 'message: testSize(25)
should return \"Huge\"');"
],
"type": "waypoint",
"challengeType": 1,
@@ -3428,7 +3428,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function caseInSwitch(val) {",
" var answer = \"\";",
" // Only change code below this line",
" ",
@@ -3439,20 +3439,20 @@
"}",
"",
"// Change this value to test",
- "myTest(1);",
+ "caseInSwitch(1);",
""
],
"solutions": [
- "function myTest(val) {\n var answer = \"\";\n\n switch (val) {\n case 1:\n answer = \"alpha\";\n break;\n case 2:\n answer = \"beta\";\n break;\n case 3:\n answer = \"gamma\";\n break;\n case 4:\n answer = \"delta\";\n }\n return answer; \n}"
+ "function caseInSwitch(val) {\n var answer = \"\";\n\n switch (val) {\n case 1:\n answer = \"alpha\";\n break;\n case 2:\n answer = \"beta\";\n break;\n case 3:\n answer = \"gamma\";\n break;\n case 4:\n answer = \"delta\";\n }\n return answer; \n}"
],
"MDNlinks": [
"Switch Statement"
],
"tests": [
- "assert(myTest(1) === \"alpha\", 'message: myTest(1) should have a value of \"alpha\"');",
- "assert(myTest(2) === \"beta\", 'message: myTest(2) should have a value of \"beta\"');",
- "assert(myTest(3) === \"gamma\", 'message: myTest(3) should have a value of \"gamma\"');",
- "assert(myTest(4) === \"delta\", 'message: myTest(4) should have a value of \"delta\"');",
+ "assert(caseInSwitch(1) === \"alpha\", 'message: caseInSwitch(1) should have a value of \"alpha\"');",
+ "assert(caseInSwitch(2) === \"beta\", 'message: caseInSwitch(2) should have a value of \"beta\"');",
+ "assert(caseInSwitch(3) === \"gamma\", 'message: caseInSwitch(3) should have a value of \"gamma\"');",
+ "assert(caseInSwitch(4) === \"delta\", 'message: caseInSwitch(4) should have a value of \"delta\"');",
"assert(!/else/g.test(code) || !/if/g.test(code), 'message: You should not use any if
or else
statements');",
"assert(code.match(/break/g).length > 2, 'message: You should have at least 3 break
statements');"
],
@@ -3480,7 +3480,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function switchOfStuff(val) {",
" var answer = \"\";",
" // Only change code below this line",
" ",
@@ -3491,18 +3491,18 @@
"}",
"",
"// Change this value to test",
- "myTest(1);",
+ "switchOfStuff(1);",
""
],
"solutions": [
- "function myTest(val) {\n var answer = \"\";\n\n switch(val) {\n case \"a\":\n answer = \"apple\";\n break;\n case \"b\":\n answer = \"bird\";\n break;\n case \"c\":\n answer = \"cat\";\n break;\n default:\n answer = \"stuff\";\n }\n return answer; \n}"
+ "function switchOfStuff(val) {\n var answer = \"\";\n\n switch(val) {\n case \"a\":\n answer = \"apple\";\n break;\n case \"b\":\n answer = \"bird\";\n break;\n case \"c\":\n answer = \"cat\";\n break;\n default:\n answer = \"stuff\";\n }\n return answer; \n}"
],
"tests": [
- "assert(myTest(\"a\") === \"apple\", 'message: myTest(\"a\") should have a value of \"apple\"');",
- "assert(myTest(\"b\") === \"bird\", 'message: myTest(\"b\") should have a value of \"bird\"');",
- "assert(myTest(\"c\") === \"cat\", 'message: myTest(\"c\") should have a value of \"cat\"');",
- "assert(myTest(\"d\") === \"stuff\", 'message: myTest(\"d\") should have a value of \"stuff\"');",
- "assert(myTest(4) === \"stuff\", 'message: myTest(4) should have a value of \"stuff\"');",
+ "assert(switchOfStuff(\"a\") === \"apple\", 'message: switchOfStuff(\"a\") should have a value of \"apple\"');",
+ "assert(switchOfStuff(\"b\") === \"bird\", 'message: switchOfStuff(\"b\") should have a value of \"bird\"');",
+ "assert(switchOfStuff(\"c\") === \"cat\", 'message: switchOfStuff(\"c\") should have a value of \"cat\"');",
+ "assert(switchOfStuff(\"d\") === \"stuff\", 'message: switchOfStuff(\"d\") should have a value of \"stuff\"');",
+ "assert(switchOfStuff(4) === \"stuff\", 'message: switchOfStuff(4) should have a value of \"stuff\"');",
"assert(!/else/g.test(code) || !/if/g.test(code), 'message: You should not use any if
or else
statements');",
"assert(code.match(/break/g).length > 2, 'message: You should have at least 3 break
statements');"
],
@@ -3530,7 +3530,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function sequentialSizes(val) {",
" var answer = \"\";",
" // Only change code below this line",
" ",
@@ -3541,22 +3541,22 @@
"}",
"",
"// Change this value to test",
- "myTest(1);",
+ "sequentialSizes(1);",
""
],
"solutions": [
- "function myTest(val) {\n var answer = \"\";\n \n switch (val) {\n case 1:\n case 2:\n case 3:\n answer = \"Low\";\n break;\n case 4:\n case 5:\n case 6:\n answer = \"Mid\";\n break;\n case 7:\n case 8:\n case 9:\n answer = \"High\";\n }\n \n return answer; \n}"
+ "function sequentialSizes(val) {\n var answer = \"\";\n \n switch (val) {\n case 1:\n case 2:\n case 3:\n answer = \"Low\";\n break;\n case 4:\n case 5:\n case 6:\n answer = \"Mid\";\n break;\n case 7:\n case 8:\n case 9:\n answer = \"High\";\n }\n \n return answer; \n}"
],
"tests": [
- "assert(myTest(1) === \"Low\", 'message: myTest(1)
should return \"Low\"');",
- "assert(myTest(2) === \"Low\", 'message: myTest(2)
should return \"Low\"');",
- "assert(myTest(3) === \"Low\", 'message: myTest(3)
should return \"Low\"');",
- "assert(myTest(4) === \"Mid\", 'message: myTest(4)
should return \"Mid\"');",
- "assert(myTest(5) === \"Mid\", 'message: myTest(5)
should return \"Mid\"');",
- "assert(myTest(6) === \"Mid\", 'message: myTest(6)
should return \"Mid\"');",
- "assert(myTest(7) === \"High\", 'message: myTest(7)
should return \"High\"');",
- "assert(myTest(8) === \"High\", 'message: myTest(8)
should return \"High\"');",
- "assert(myTest(9) === \"High\", 'message: myTest(9)
should return \"High\"');",
+ "assert(sequentialSizes(1) === \"Low\", 'message: sequentialSizes(1)
should return \"Low\"');",
+ "assert(sequentialSizes(2) === \"Low\", 'message: sequentialSizes(2)
should return \"Low\"');",
+ "assert(sequentialSizes(3) === \"Low\", 'message: sequentialSizes(3)
should return \"Low\"');",
+ "assert(sequentialSizes(4) === \"Mid\", 'message: sequentialSizes(4)
should return \"Mid\"');",
+ "assert(sequentialSizes(5) === \"Mid\", 'message: sequentialSizes(5)
should return \"Mid\"');",
+ "assert(sequentialSizes(6) === \"Mid\", 'message: sequentialSizes(6)
should return \"Mid\"');",
+ "assert(sequentialSizes(7) === \"High\", 'message: sequentialSizes(7)
should return \"High\"');",
+ "assert(sequentialSizes(8) === \"High\", 'message: sequentialSizes(8)
should return \"High\"');",
+ "assert(sequentialSizes(9) === \"High\", 'message: sequentialSizes(9)
should return \"High\"');",
"assert(!/else/g.test(code) || !/if/g.test(code), 'message: You should not use any if
or else
statements');",
"assert(code.match(/case/g).length === 9, 'message: You should have nine case
statements');"
],
@@ -3585,7 +3585,7 @@
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
- "function myTest(val) {",
+ "function chainToSwitch(val) {",
" var answer = \"\";",
" // Only change code below this line",
" ",
@@ -3606,23 +3606,23 @@
"}",
"",
"// Change this value to test",
- "myTest(7);",
+ "chainToSwitch(7);",
""
],
"solutions": [
- "function myTest(val) {\n var answer = \"\";\n\n switch (val) {\n case \"bob\":\n answer = \"Marley\";\n break;\n case 42:\n answer = \"The Answer\";\n break;\n case 1:\n answer = \"There is no #1\";\n break;\n case 99:\n answer = \"Missed me by this much!\";\n break;\n case 7:\n answer = \"Ate Nine\";\n }\n return answer; \n}"
+ "function chainToSwitch(val) {\n var answer = \"\";\n\n switch (val) {\n case \"bob\":\n answer = \"Marley\";\n break;\n case 42:\n answer = \"The Answer\";\n break;\n case 1:\n answer = \"There is no #1\";\n break;\n case 99:\n answer = \"Missed me by this much!\";\n break;\n case 7:\n answer = \"Ate Nine\";\n }\n return answer; \n}"
],
"tests": [
"assert(!/else/g.test(code), 'message: You should not use any else
statements');",
"assert(!/if/g.test(code), 'message: You should not use any if
statements');",
"assert(code.match(/break/g).length >= 4, 'message: You should have at least four break
statements');",
- "assert(myTest(\"bob\") === \"Marley\", 'message: myTest(\"bob\")
should be \"Marley\"');",
- "assert(myTest(42) === \"The Answer\", 'message: myTest(42)
should be \"The Answer\"');",
- "assert(myTest(1) === \"There is no #1\", 'message: myTest(1)
should be \"There is no #1\"');",
- "assert(myTest(99) === \"Missed me by this much!\", 'message: myTest(99)
should be \"Missed me by this much!\"');",
- "assert(myTest(7) === \"Ate Nine\", 'message: myTest(7)
should be \"Ate Nine\"');",
- "assert(myTest(\"John\") === \"\", 'message: myTest(\"John\")
should be \"\" (empty string)');",
- "assert(myTest(156) === \"\", 'message: myTest(156)
should be \"\" (empty string)');"
+ "assert(chainToSwitch(\"bob\") === \"Marley\", 'message: chainToSwitch(\"bob\")
should be \"Marley\"');",
+ "assert(chainToSwitch(42) === \"The Answer\", 'message: chainToSwitch(42)
should be \"The Answer\"');",
+ "assert(chainToSwitch(1) === \"There is no #1\", 'message: chainToSwitch(1)
should be \"There is no #1\"');",
+ "assert(chainToSwitch(99) === \"Missed me by this much!\", 'message: chainToSwitch(99)
should be \"Missed me by this much!\"');",
+ "assert(chainToSwitch(7) === \"Ate Nine\", 'message: chainToSwitch(7)
should be \"Ate Nine\"');",
+ "assert(chainToSwitch(\"John\") === \"\", 'message: chainToSwitch(\"John\")
should be \"\" (empty string)');",
+ "assert(chainToSwitch(156) === \"\", 'message: chainToSwitch(156)
should be \"\" (empty string)');"
],
"type": "waypoint",
"challengeType": 1,
@@ -4524,27 +4524,27 @@
"var collectionCopy = JSON.parse(JSON.stringify(collection));",
"",
"// Only change code below this line",
- "function update(id, prop, value) {",
+ "function updateRecords(id, prop, value) {",
"",
"",
" return collection;",
"}",
"",
"// Alter values below to test your code",
- "update(5439, \"artist\", \"ABBA\");",
+ "updateRecords(5439, \"artist\", \"ABBA\");",
""
],
"tail": [
"(function(x) { return \"collection = \\n\" + JSON.stringify(x, '\\n', 2); })(collection);"
],
"solutions": [
- "var collection = {\n 2548: {\n album: \"Slippery When Wet\",\n artist: \"Bon Jovi\",\n tracks: [ \n \"Let It Rock\", \n \"You Give Love a Bad Name\" \n ]\n },\n 2468: {\n album: \"1999\",\n artist: \"Prince\",\n tracks: [ \n \"1999\", \n \"Little Red Corvette\" \n ]\n },\n 1245: {\n artist: \"Robert Palmer\",\n tracks: [ ]\n },\n 5439: {\n album: \"ABBA Gold\"\n }\n};\n// Keep a copy of the collection for tests\nvar collectionCopy = JSON.parse(JSON.stringify(collection));\n\n// Only change code below this line\nfunction update(id, prop, value) {\n if(value !== \"\") {\n if(prop === \"tracks\") {\n collection[id][prop].push(value);\n } else {\n collection[id][prop] = value;\n }\n } else {\n delete collection[id][prop];\n }\n\n return collection;\n}"
+ "var collection = {\n 2548: {\n album: \"Slippery When Wet\",\n artist: \"Bon Jovi\",\n tracks: [ \n \"Let It Rock\", \n \"You Give Love a Bad Name\" \n ]\n },\n 2468: {\n album: \"1999\",\n artist: \"Prince\",\n tracks: [ \n \"1999\", \n \"Little Red Corvette\" \n ]\n },\n 1245: {\n artist: \"Robert Palmer\",\n tracks: [ ]\n },\n 5439: {\n album: \"ABBA Gold\"\n }\n};\n// Keep a copy of the collection for tests\nvar collectionCopy = JSON.parse(JSON.stringify(collection));\n\n// Only change code below this line\nfunction updateRecords(id, prop, value) {\n if(value !== \"\") {\n if(prop === \"tracks\") {\n collection[id][prop].push(value);\n } else {\n collection[id][prop] = value;\n }\n } else {\n delete collection[id][prop];\n }\n\n return collection;\n}"
],
"tests": [
- "collection = collectionCopy; assert(update(5439, \"artist\", \"ABBA\")[5439][\"artist\"] === \"ABBA\", 'message: After update(5439, \"artist\", \"ABBA\")
, artist
should be \"ABBA\"
');",
- "update(2548, \"artist\", \"\"); assert(!collection[2548].hasOwnProperty(\"artist\"), 'message: After update(2548, \"artist\", \"\")
, artist
should not be set');",
- "assert(update(1245, \"tracks\", \"Addicted to Love\")[1245][\"tracks\"].pop() === \"Addicted to Love\", 'message: After update(1245, \"tracks\", \"Addicted to Love\")
, tracks
should have \"Addicted to Love\"
as the last element.');",
- "update(2548, \"tracks\", \"\"); assert(!collection[2548].hasOwnProperty(\"tracks\"), 'message: After update(2548, \"tracks\", \"\")
, tracks
should not be set');"
+ "collection = collectionCopy; assert(updateRecords(5439, \"artist\", \"ABBA\")[5439][\"artist\"] === \"ABBA\", 'message: After updateRecords(5439, \"artist\", \"ABBA\")
, artist
should be \"ABBA\"
');",
+ "updateRecords(2548, \"artist\", \"\"); assert(!collection[2548].hasOwnProperty(\"artist\"), 'message: After updateRecords(2548, \"artist\", \"\")
, artist
should not be set');",
+ "assert(updateRecords(1245, \"tracks\", \"Addicted to Love\")[1245][\"tracks\"].pop() === \"Addicted to Love\", 'message: After updateRecords(1245, \"tracks\", \"Addicted to Love\")
, tracks
should have \"Addicted to Love\"
as the last element.');",
+ "updateRecords(2548, \"tracks\", \"\"); assert(!collection[2548].hasOwnProperty(\"tracks\"), 'message: After updateRecords(2548, \"tracks\", \"\")
, tracks
should not be set');"
],
"type": "checkpoint",
"challengeType": 1,
@@ -4915,24 +4915,24 @@
"];",
"",
"",
- "function lookUp(firstName, prop){",
+ "function lookUpProfile(firstName, prop){",
"// Only change code below this line",
"",
"// Only change code above this line",
"}",
"",
"// Change these values to test your function",
- "lookUp(\"Akira\", \"likes\");"
+ "lookUpProfile(\"Akira\", \"likes\");"
],
"solutions": [
- "var contacts = [\n {\n \"firstName\": \"Akira\",\n \"lastName\": \"Laine\",\n \"number\": \"0543236543\",\n \"likes\": [\"Pizza\", \"Coding\", \"Brownie Points\"]\n },\n {\n \"firstName\": \"Harry\",\n \"lastName\": \"Potter\",\n \"number\": \"0994372684\",\n \"likes\": [\"Hogwarts\", \"Magic\", \"Hagrid\"]\n },\n {\n \"firstName\": \"Sherlock\",\n \"lastName\": \"Holmes\",\n \"number\": \"0487345643\",\n \"likes\": [\"Intriguing Cases\", \"Violin\"]\n },\n {\n \"firstName\": \"Kristian\",\n \"lastName\": \"Vos\",\n \"number\": \"unknown\",\n \"likes\": [\"Javascript\", \"Gaming\", \"Foxes\"]\n },\n];\n\n\n//Write your function in between these comments\nfunction lookUp(name, prop){\n for(var i in contacts){\n if(contacts[i].firstName === name) {\n return contacts[i][prop] || \"No such property\";\n }\n }\n return \"No such contact\";\n}\n//Write your function in between these comments\n\nlookUp(\"Akira\", \"likes\");"
+ "var contacts = [\n {\n \"firstName\": \"Akira\",\n \"lastName\": \"Laine\",\n \"number\": \"0543236543\",\n \"likes\": [\"Pizza\", \"Coding\", \"Brownie Points\"]\n },\n {\n \"firstName\": \"Harry\",\n \"lastName\": \"Potter\",\n \"number\": \"0994372684\",\n \"likes\": [\"Hogwarts\", \"Magic\", \"Hagrid\"]\n },\n {\n \"firstName\": \"Sherlock\",\n \"lastName\": \"Holmes\",\n \"number\": \"0487345643\",\n \"likes\": [\"Intriguing Cases\", \"Violin\"]\n },\n {\n \"firstName\": \"Kristian\",\n \"lastName\": \"Vos\",\n \"number\": \"unknown\",\n \"likes\": [\"Javascript\", \"Gaming\", \"Foxes\"]\n },\n];\n\n\n//Write your function in between these comments\nfunction lookUpProfile(name, prop){\n for(var i in contacts){\n if(contacts[i].firstName === name) {\n return contacts[i][prop] || \"No such property\";\n }\n }\n return \"No such contact\";\n}\n//Write your function in between these comments\n\nlookUpProfile(\"Akira\", \"likes\");"
],
"tests": [
- "assert(lookUp('Kristian','lastName') === \"Vos\", 'message: \"Kristian\", \"lastName\"
should return \"Vos\"
');",
- "assert.deepEqual(lookUp(\"Sherlock\", \"likes\"), [\"Intriguing Cases\", \"Violin\"], 'message: \"Sherlock\", \"likes\"
should return [\"Intriguing Cases\", \"Violin\"]
');",
- "assert(typeof lookUp(\"Harry\", \"likes\") === \"object\", 'message: \"Harry\",\"likes\"
should return an array');",
- "assert(lookUp(\"Bob\", \"number\") === \"No such contact\", 'message: \"Bob\", \"number\"
should return \"No such contact\"');",
- "assert(lookUp(\"Akira\", \"address\") === \"No such property\", 'message: \"Akira\", \"address\"
should return \"No such property\"');"
+ "assert(lookUpProfile('Kristian','lastName') === \"Vos\", 'message: \"Kristian\", \"lastName\"
should return \"Vos\"
');",
+ "assert.deepEqual(lookUpProfile(\"Sherlock\", \"likes\"), [\"Intriguing Cases\", \"Violin\"], 'message: \"Sherlock\", \"likes\"
should return [\"Intriguing Cases\", \"Violin\"]
');",
+ "assert(typeof lookUpProfile(\"Harry\", \"likes\") === \"object\", 'message: \"Harry\",\"likes\"
should return an array');",
+ "assert(lookUpProfile(\"Bob\", \"number\") === \"No such contact\", 'message: \"Bob\", \"number\"
should return \"No such contact\"');",
+ "assert(lookUpProfile(\"Akira\", \"address\") === \"No such property\", 'message: \"Akira\", \"address\"
should return \"No such property\"');"
],
"type": "checkpoint",
"challengeType": 1,
@@ -4955,10 +4955,10 @@
"JavaScript has a Math.random()
function that generates a random decimal number between 0
(inclusive) and not quite up to 1
(exclusive). Thus Math.random()
can return a 0
but never quite return a 1
",
"Note
Like Storing Values with the Equal Operator, all function calls will be resolved before the return
executes, so we can simply return
the value of the Math.random()
function.",
"Instructions
",
- "Change myFunction
to return a random number instead of returning 0
."
+ "Change randomFraction
to return a random number instead of returning 0
."
],
"challengeSeed": [
- "function myFunction() {",
+ "function randomFraction() {",
"",
" // Only change code below this line.",
"",
@@ -4968,14 +4968,14 @@
"}"
],
"tail": [
- "(function(){return myFunction();})();"
+ "(function(){return randomFraction();})();"
],
"solutions": [
- "function myFunction() {\n return Math.random();\n}"
+ "function randomFraction() {\n return Math.random();\n}"
],
"tests": [
- "assert(typeof myFunction() === \"number\", 'message: myFunction
should return a random number.');",
- "assert((myFunction()+''). match(/\\./g), 'message: The number returned by myFunction
should be a decimal.');",
+ "assert(typeof randomFraction() === \"number\", 'message: randomFraction
should return a random number.');",
+ "assert((randomFraction()+''). match(/\\./g), 'message: The number returned by randomFraction
should be a decimal.');",
"assert(code.match(/Math\\.random/g).length >= 0, 'message: You should be using Math.random
to generate the random decimal number.');"
],
"type": "waypoint",
@@ -4985,7 +4985,7 @@
"Los números aleatorios son útiles para crear un comportamiento aleatorio.",
"JavaScript tiene una función Math.random()
que genera un número decimal aleatorio.",
"Instrucciones
",
- "Cambia myFunction
para que devuelva un número al azar en lugar de devolver 0
.",
+ "Cambia randomFraction
para que devuelva un número al azar en lugar de devolver 0
.",
"Ten en cuenta que puedes retornar lo retornado por una función, igual que harías para devolver una variable o valor."
]
},
@@ -5005,7 +5005,7 @@
"challengeSeed": [
"var randomNumberBetween0and19 = Math.floor(Math.random() * 20);",
"",
- "function myFunction() {",
+ "function randomWholeNum() {",
"",
" // Only change code below this line.",
"",
@@ -5013,13 +5013,13 @@
"}"
],
"tail": [
- "(function(){return myFunction();})();"
+ "(function(){return randomWholeNum();})();"
],
"solutions": [
- "var randomNumberBetween0and19 = Math.floor(Math.random() * 20);\n\nfunction myFunction() {\n return Math.floor(Math.random() * 10);\n}"
+ "var randomNumberBetween0and19 = Math.floor(Math.random() * 20);\n\nfunction randomWholeNum() {\n return Math.floor(Math.random() * 10);\n}"
],
"tests": [
- "assert(typeof myFunction() === \"number\" && (function(){var r = myFunction();return Math.floor(r) === r;})(), 'message: The result of myFunction
should be a whole number.');",
+ "assert(typeof randomWholeNum() === \"number\" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})(), 'message: The result of randomWholeNum
should be a whole number.');",
"assert(code.match(/Math.random/g).length > 1, 'message: You should be using Math.random
to generate a random number.');",
"assert(code.match(/\\(\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\*\\s*?10\\s*?\\)/g) || code.match(/\\(\\s*?10\\s*?\\*\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\)/g), 'message: You should have multiplied the result of Math.random
by 10 to make it a number that is between zero and nine.');",
"assert(code.match(/Math.floor/g).length > 1, 'message: You should use Math.floor
to remove the decimal part of the number.');"