feat(package): Initial Curriculum separation (#17174)
* feat(package): Initial Curriculum separation * feat(package): Add org scope to package * chore(ooops): Remove development file * feat(npm): Add .npmignore * fix(paths): Fix curriculum paths * feat(build): Add a build step * chore(seed): Move package file back to seed * fix(ignore): Fix .npmIgnore file * chore(docs): Update README * chore(seed): Rename coding interview blocks * fix(seed): Challenge files now fit into learn * chore(seed): Update seed files for use in learn * chore(escapes): Unescape script tags of jQuery
This commit is contained in:
committed by
mrugesh mohapatra
parent
63482406ea
commit
ee66d84ccb
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -4,37 +4,6 @@
|
||||
"time": "1 hour",
|
||||
"helpRoom": "Help",
|
||||
"challenges": [
|
||||
{
|
||||
"id": "587d7b83367417b2b2512b32",
|
||||
"title": "Introduction to the Debugging Challenges",
|
||||
"description": [
|
||||
[
|
||||
"",
|
||||
"",
|
||||
"Debugging is a valuable and (unfortunately) necessary tool for programmers. It follows the testing phase of checking if your code works as intended, and discovering it does not. Debugging is the process of finding exactly what isn't working and fixing it.",
|
||||
""
|
||||
],
|
||||
[
|
||||
"",
|
||||
"",
|
||||
"After spending time creating a brilliant block of code, it is tough realizing it may have errors. These issues generally come in three forms: 1) syntax errors that prevent a program from running, 2) runtime errors when code fails to execute or has unexpected behavior, and 3) semantic (or logical) errors when code doesn't do what it's meant to.<br><br>Modern code editors (and experience) can help identify syntax errors. Semantic and runtime errors are harder to find. They may cause your program to crash, make it run forever, or give incorrect output. Think of debugging as trying to understand why your code is behaving the way it is.<br><br>Example of a syntax error - often detected by the code editor:<br><br><blockquote>funtion willNotWork( {<br> console.log(\"Yuck\");<br>}<br>// \"function\" keyword is misspelled and there's a missing parenthesis</blockquote><br><br>Here's an example of a runtime error - often detected while the program executes:<br><br><blockquote>function loopy() {<br> while(true) {<br> console.log(\"Hello, world!\");<br> }<br>}<br>// Calling loopy starts an infinite loop, which may crash your browser</blockquote><br><br>Example of a semantic error - often detected after testing code output:<br><br><blockquote>function calcAreaOfRect(w, h) {<br> return w + h; // This should be w * h<br>}<br>let myRectArea = calcAreaOfRect(2, 3);<br>// Correct syntax and the program executes, but this gives the wrong answer</blockquote>",
|
||||
""
|
||||
],
|
||||
[
|
||||
"",
|
||||
"",
|
||||
"Debugging is frustrating, but it helps to develop (and follow) a step-by-step approach to review your code. This means checking the intermediate values and types of variables to see if they are what they should be. You can start with a simple process of elimination.<br><br>For example, if function A works and returns what it's supposed to, then function B may have the issue. Or start checking values in a block of code from the middle to try to cut the search space in half. A problem in one spot indicates a bug in the first half of the code. If not, it's likely in the second.<br><br>This section will cover a couple helpful tools to find bugs, and some of the common forms they take. Fortunately, debugging is a learnable skill that just requires a little patience and practice to master.",
|
||||
""
|
||||
]
|
||||
],
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeSeed": [],
|
||||
"tests": [],
|
||||
"type": "waypoint",
|
||||
"challengeType": 7,
|
||||
"isRequired": false,
|
||||
"translations": {}
|
||||
},
|
||||
{
|
||||
"id": "587d7b83367417b2b2512b33",
|
||||
"title": "Use the JavaScript Console to Check the Value of a Variable",
|
||||
@ -47,25 +16,37 @@
|
||||
"<hr>",
|
||||
"Use the <code>console.log()</code> method to print the value of the variable <code>a</code> where noted in the code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"let a = 5;",
|
||||
"let b = 1;",
|
||||
"a++;",
|
||||
"// Add your code below this line",
|
||||
"",
|
||||
"",
|
||||
"let sumAB = a + b;",
|
||||
"console.log(sumAB);"
|
||||
],
|
||||
"tests": [
|
||||
"assert(code.match(/console\\.log\\(a\\)/g), 'message: Your code should use <code>console.log()</code> to check the value of the variable <code>a</code>.');"
|
||||
{
|
||||
"text": "Your code should use <code>console.log()</code> to check the value of the variable <code>a</code>.",
|
||||
"testString": "assert(code.match(/console\\.log\\(a\\)/g), 'Your code should use <code>console.log()</code> to check the value of the variable <code>a</code>.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"let a = 5;",
|
||||
"let b = 1;",
|
||||
"a++;",
|
||||
"// Add your code below this line",
|
||||
"",
|
||||
"",
|
||||
"let sumAB = a + b;",
|
||||
"console.log(sumAB);"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b83367417b2b2512b37",
|
||||
@ -81,31 +62,49 @@
|
||||
"Use <code>console.log()</code> to print the variables in the code where indicated.",
|
||||
""
|
||||
],
|
||||
"challengeSeed": [
|
||||
"// Open your browser console",
|
||||
"let outputTwo = \"This will print to the browser console 2 times\";",
|
||||
"// Use console.log() to print the outputTwo variable",
|
||||
"",
|
||||
"",
|
||||
"let outputOne = \"Try to get this to log only once to the browser console\";",
|
||||
"// Use console.clear() in the next line to print the outputOne only once",
|
||||
"",
|
||||
"",
|
||||
"// Use console.log() to print the outputOne variable",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"tests": [
|
||||
"assert(code.match(/console\\.log\\(outputTwo\\)/g), 'message: Use <code>console.log()</code> to print the <code>outputTwice</code> variable. In your Browser Console this should print out the value of the variable two times.');",
|
||||
"assert(code.match(/console\\.log\\(outputOne\\)/g), 'message: Use <code>console.log()</code> to print the <code>outputOne</code> variable.');",
|
||||
"assert(code.match(/(?<!\\/\\/ Use )console\\.clear\\(\\)/g), 'message: Use <code>console.clear()</code> to modify your output so that <code>outputOne</code> variable only outputs once.');"
|
||||
{
|
||||
"text": "Use <code>console.log()</code> to print the <code>outputTwice</code> variable. In your Browser Console this should print out the value of the variable two times.",
|
||||
"testString": "assert(code.match(/console\\.log\\(outputTwo\\)/g), 'Use <code>console.log()</code> to print the <code>outputTwice</code> variable. In your Browser Console this should print out the value of the variable two times.');"
|
||||
},
|
||||
{
|
||||
"text": "Use <code>console.log()</code> to print the <code>outputOne</code> variable.",
|
||||
"testString": "assert(code.match(/console\\.log\\(outputOne\\)/g), 'Use <code>console.log()</code> to print the <code>outputOne</code> variable.');"
|
||||
},
|
||||
{
|
||||
"text": "Use <code>console.clear()</code> to modify your output so that <code>outputOne</code> variable only outputs once.",
|
||||
"testString": "assert(code.match(/(?<!\\/\\/ Use )console\\.clear\\(\\)/g), 'Use <code>console.clear()</code> to modify your output so that <code>outputOne</code> variable only outputs once.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"// Open your browser console",
|
||||
"let outputTwo = \"This will print to the browser console 2 times\";",
|
||||
"// Use console.log() to print the outputTwo variable",
|
||||
"",
|
||||
"",
|
||||
"let outputOne = \"Try to get this to log only once to the browser console\";",
|
||||
"// Use console.clear() in the next line to print the outputOne only once",
|
||||
"",
|
||||
"",
|
||||
"// Use console.log() to print the outputOne variable",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b84367417b2b2512b34",
|
||||
@ -118,24 +117,42 @@
|
||||
"<hr>",
|
||||
"Add two <code>console.log()</code> statements to check the <code>typeof</code> each of the two variables <code>seven</code> and <code>three</code> in the code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"let seven = 7;",
|
||||
"let three = \"3\";",
|
||||
"console.log(seven + three);",
|
||||
"// Add your code below this line",
|
||||
""
|
||||
],
|
||||
"tests": [
|
||||
"assert(code.match(/console\\.log\\(typeof[\\( ].*\\)?\\)/g).length == 2, 'message: Your code should use <code>typeof</code> in two <code>console.log()</code> statements to check the type of the variables.');",
|
||||
"assert(code.match(/typeof[\\( ]seven\\)?/g), 'message: Your code should use <code>typeof</code> to check the type of the variable <code>seven</code>.');",
|
||||
"assert(code.match(/typeof[\\( ]three\\)?/g), 'message: Your code should use <code>typeof</code> to check the type of the variable <code>three</code>.');"
|
||||
{
|
||||
"text": "Your code should use <code>typeof</code> in two <code>console.log()</code> statements to check the type of the variables.",
|
||||
"testString": "assert(code.match(/console\\.log\\(typeof[\\( ].*\\)?\\)/g).length == 2, 'Your code should use <code>typeof</code> in two <code>console.log()</code> statements to check the type of the variables.');"
|
||||
},
|
||||
{
|
||||
"text": "Your code should use <code>typeof</code> to check the type of the variable <code>seven</code>.",
|
||||
"testString": "assert(code.match(/typeof[\\( ]seven\\)?/g), 'Your code should use <code>typeof</code> to check the type of the variable <code>seven</code>.');"
|
||||
},
|
||||
{
|
||||
"text": "Your code should use <code>typeof</code> to check the type of the variable <code>three</code>.",
|
||||
"testString": "assert(code.match(/typeof[\\( ]three\\)?/g), 'Your code should use <code>typeof</code> to check the type of the variable <code>three</code>.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"let seven = 7;",
|
||||
"let three = \"3\";",
|
||||
"console.log(seven + three);",
|
||||
"// Add your code below this line",
|
||||
""
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b84367417b2b2512b35",
|
||||
@ -146,25 +163,49 @@
|
||||
"<hr>",
|
||||
"Fix the two spelling errors in the code so the <code>netWorkingCapital</code> calculation works."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"let receivables = 10;",
|
||||
"let payables = 8;",
|
||||
"let netWorkingCapital = recievables - payable;",
|
||||
"console.log(`Net working capital is: ${netWorkingCapital}`);"
|
||||
],
|
||||
"tests": [
|
||||
"assert(netWorkingCapital === 2, 'message: Check the spelling of the two variables used in the netWorkingCapital calculation, the console output should show that \"Net working capital is: 2\".');",
|
||||
"assert(!code.match(/recievables/g), 'message: There should be no instances of mis-spelled variables in the code.');",
|
||||
"assert(code.match(/receivables/g).length == 2, 'message: The <code>receivables</code> variable should be declared and used properly in the code.');",
|
||||
"assert(!code.match(/payable;/g), 'message: There should be no instances of mis-spelled variables in the code.');",
|
||||
"assert(code.match(/payables/g).length == 2, 'message: The <code>payables</code> variable should be declared and used properly in the code.');"
|
||||
{
|
||||
"text": "Check the spelling of the two variables used in the netWorkingCapital calculation, the console output should show that \"Net working capital is: 2\".",
|
||||
"testString": "assert(netWorkingCapital === 2, 'Check the spelling of the two variables used in the netWorkingCapital calculation, the console output should show that \"Net working capital is: 2\".');"
|
||||
},
|
||||
{
|
||||
"text": "There should be no instances of mis-spelled variables in the code.",
|
||||
"testString": "assert(!code.match(/recievables/g), 'There should be no instances of mis-spelled variables in the code.');"
|
||||
},
|
||||
{
|
||||
"text": "The <code>receivables</code> variable should be declared and used properly in the code.",
|
||||
"testString": "assert(code.match(/receivables/g).length == 2, 'The <code>receivables</code> variable should be declared and used properly in the code.');"
|
||||
},
|
||||
{
|
||||
"text": "There should be no instances of mis-spelled variables in the code.",
|
||||
"testString": "assert(!code.match(/payable;/g), 'There should be no instances of mis-spelled variables in the code.');"
|
||||
},
|
||||
{
|
||||
"text": "The <code>payables</code> variable should be declared and used properly in the code.",
|
||||
"testString": "assert(code.match(/payables/g).length == 2, 'The <code>payables</code> variable should be declared and used properly in the code.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"let receivables = 10;",
|
||||
"let payables = 8;",
|
||||
"let netWorkingCapital = recievables - payable;",
|
||||
"console.log(`Net working capital is: ${netWorkingCapital}`);"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b84367417b2b2512b36",
|
||||
@ -175,21 +216,36 @@
|
||||
"<hr>",
|
||||
"Fix the two pair errors in the code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"let myArray = [1, 2, 3;",
|
||||
"let arraySum = myArray.reduce((previous, current => previous + current);",
|
||||
"console.log(`Sum of array values is: ${arraySum}`);"
|
||||
],
|
||||
"tests": [
|
||||
"assert(code.match(/myArray\\s*?=\\s*?\\[\\s*?1\\s*?,\\s*?2\\s*?,\\s*?3\\s*?\\];/g), 'message: Your code should fix the missing piece of the array.');",
|
||||
"assert(arraySum === 6, 'message: Your code should fix the missing piece of the <code>.reduce()</code> method. The console output should show that \"Sum of array values is: 6\".');"
|
||||
{
|
||||
"text": "Your code should fix the missing piece of the array.",
|
||||
"testString": "assert(code.match(/myArray\\s*?=\\s*?\\[\\s*?1\\s*?,\\s*?2\\s*?,\\s*?3\\s*?\\];/g), 'Your code should fix the missing piece of the array.');"
|
||||
},
|
||||
{
|
||||
"text": "Your code should fix the missing piece of the <code>.reduce()</code> method. The console output should show that \"Sum of array values is: 6\".",
|
||||
"testString": "assert(arraySum === 6, 'Your code should fix the missing piece of the <code>.reduce()</code> method. The console output should show that \"Sum of array values is: 6\".');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"let myArray = [1, 2, 3;",
|
||||
"let arraySum = myArray.reduce((previous, current => previous + current);",
|
||||
"console.log(`Sum of array values is: ${arraySum}`);"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b84367417b2b2512b37",
|
||||
@ -204,20 +260,35 @@
|
||||
"<hr>",
|
||||
"Fix the string so it either uses different quotes for the <code>href</code> value, or escape the existing ones. Keep the double quote marks around the entire string."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"let innerHtml = \"<p>Click here to <a href=\"#Home\">return home</a></p>\";",
|
||||
"console.log(innerHtml);"
|
||||
],
|
||||
"tests": [
|
||||
"assert(code.match(/<a href=\\s*?('|\\\\\")#Home\\1\\s*?>/g), 'message: Your code should fix the quotes around the <code>href</code> value \"#Home\" by either changing or escaping them.');",
|
||||
"assert(code.match(/\"<p>.*?<\\/p>\";/g), 'message: Your code should keep the double quotes around the entire string.');"
|
||||
{
|
||||
"text": "Your code should fix the quotes around the <code>href</code> value \"#Home\" by either changing or escaping them.",
|
||||
"testString": "assert(code.match(/<a href=\\s*?('|\\\\\")#Home\\1\\s*?>/g), 'Your code should fix the quotes around the <code>href</code> value \"#Home\" by either changing or escaping them.');"
|
||||
},
|
||||
{
|
||||
"text": "Your code should keep the double quotes around the entire string.",
|
||||
"testString": "assert(code.match(/\"<p>.*?<\\/p>\";/g), 'Your code should keep the double quotes around the entire string.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"let innerHtml = \"<p>Click here to <a href=\"#Home\">return home</a></p>\";",
|
||||
"console.log(innerHtml);"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b85367417b2b2512b38",
|
||||
@ -231,29 +302,44 @@
|
||||
"<hr>",
|
||||
"Fix the condition so the program runs the right branch, and the appropriate value is assigned to <code>result</code>."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"let x = 7;",
|
||||
"let y = 9;",
|
||||
"let result = \"to come\";",
|
||||
"",
|
||||
"if(x = y) {",
|
||||
" result = \"Equal!\";",
|
||||
"} else {",
|
||||
" result = \"Not equal!\";",
|
||||
"}",
|
||||
"",
|
||||
"console.log(result);"
|
||||
],
|
||||
"tests": [
|
||||
"assert(result == \"Not equal!\", 'message: Your code should fix the condition so it checks for equality, instead of using assignment.');",
|
||||
"assert(code.match(/x\\s*?===?\\s*?y/g), 'message: The condition can use either <code>==</code> or <code>===</code> to test for equality.');"
|
||||
{
|
||||
"text": "Your code should fix the condition so it checks for equality, instead of using assignment.",
|
||||
"testString": "assert(result == \"Not equal!\", 'Your code should fix the condition so it checks for equality, instead of using assignment.');"
|
||||
},
|
||||
{
|
||||
"text": "The condition can use either <code>==</code> or <code>===</code> to test for equality.",
|
||||
"testString": "assert(code.match(/x\\s*?===?\\s*?y/g), 'The condition can use either <code>==</code> or <code>===</code> to test for equality.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"let x = 7;",
|
||||
"let y = 9;",
|
||||
"let result = \"to come\";",
|
||||
"",
|
||||
"if(x = y) {",
|
||||
" result = \"Equal!\";",
|
||||
"} else {",
|
||||
" result = \"Not equal!\";",
|
||||
"}",
|
||||
"",
|
||||
"console.log(result);"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b85367417b2b2512b39",
|
||||
@ -265,26 +351,41 @@
|
||||
"<hr>",
|
||||
"Fix the code so the variable <code>result</code> is set to the value returned from calling the function <code>getNine</code>."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function getNine() {",
|
||||
" let x = 6;",
|
||||
" let y = 3;",
|
||||
" return x + y;",
|
||||
"}",
|
||||
"",
|
||||
"let result = getNine;",
|
||||
"console.log(result);"
|
||||
],
|
||||
"tests": [
|
||||
"assert(result == 9, 'message: Your code should fix the variable <code>result</code> so it is set to the number that the function <code>getNine</code> returns.');",
|
||||
"assert(code.match(/getNine\\(\\)/g).length == 2, 'message: Your code should call the <code>getNine</code> function.');"
|
||||
{
|
||||
"text": "Your code should fix the variable <code>result</code> so it is set to the number that the function <code>getNine</code> returns.",
|
||||
"testString": "assert(result == 9, 'Your code should fix the variable <code>result</code> so it is set to the number that the function <code>getNine</code> returns.');"
|
||||
},
|
||||
{
|
||||
"text": "Your code should call the <code>getNine</code> function.",
|
||||
"testString": "assert(code.match(/getNine\\(\\)/g).length == 2, 'Your code should call the <code>getNine</code> function.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"function getNine() {",
|
||||
" let x = 6;",
|
||||
" let y = 3;",
|
||||
" return x + y;",
|
||||
"}",
|
||||
"",
|
||||
"let result = getNine;",
|
||||
"console.log(result);"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b85367417b2b2512b3a",
|
||||
@ -294,26 +395,41 @@
|
||||
"<hr>",
|
||||
"The function <code>raiseToPower</code> raises a base to an exponent. Unfortunately, it's not called properly - fix the code so the value of <code>power</code> is the expected 8."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function raiseToPower(b, e) {",
|
||||
" return Math.pow(b, e);",
|
||||
"}",
|
||||
"",
|
||||
"let base = 2;",
|
||||
"let exp = 3;",
|
||||
"let power = raiseToPower(exp, base);",
|
||||
"console.log(power);"
|
||||
],
|
||||
"tests": [
|
||||
"assert(power == 8, 'message: Your code should fix the variable <code>power</code> so it equals 2 raised to the 3rd power, not 3 raised to the 2nd power.');",
|
||||
"assert(code.match(/raiseToPower\\(\\s*?base\\s*?,\\s*?exp\\s*?\\);/g), 'message: Your code should use the correct order of the arguments for the <code>raiseToPower</code> function call.');"
|
||||
{
|
||||
"text": "Your code should fix the variable <code>power</code> so it equals 2 raised to the 3rd power, not 3 raised to the 2nd power.",
|
||||
"testString": "assert(power == 8, 'Your code should fix the variable <code>power</code> so it equals 2 raised to the 3rd power, not 3 raised to the 2nd power.');"
|
||||
},
|
||||
{
|
||||
"text": "Your code should use the correct order of the arguments for the <code>raiseToPower</code> function call.",
|
||||
"testString": "assert(code.match(/raiseToPower\\(\\s*?base\\s*?,\\s*?exp\\s*?\\);/g), 'Your code should use the correct order of the arguments for the <code>raiseToPower</code> function call.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"function raiseToPower(b, e) {",
|
||||
" return Math.pow(b, e);",
|
||||
"}",
|
||||
"",
|
||||
"let base = 2;",
|
||||
"let exp = 3;",
|
||||
"let power = raiseToPower(exp, base);",
|
||||
"console.log(power);"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b86367417b2b2512b3b",
|
||||
@ -325,31 +441,52 @@
|
||||
"<hr>",
|
||||
"Fix the two indexing errors in the following function so all the numbers 1 through 5 are printed to the console."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function countToFive() {",
|
||||
" let firstFive = \"12345\";",
|
||||
" let len = firstFive.length;",
|
||||
" // Fix the line below",
|
||||
" for (let i = 1; i <= len; i++) {",
|
||||
" // Do not alter code below this line",
|
||||
" console.log(firstFive[i]);",
|
||||
" }",
|
||||
"}",
|
||||
"",
|
||||
"countToFive();"
|
||||
],
|
||||
"tests": [
|
||||
"assert(code.match(/i\\s*?=\\s*?0\\s*?;/g).length == 1, 'message: Your code should set the initial condition of the loop so it starts at the first index.');",
|
||||
"assert(!code.match(/i\\s?=\\s*?1\\s*?;/g), 'message: Your code should fix the initial condition of the loop so that the index starts at 0.');",
|
||||
"assert(code.match(/i\\s*?<\\s*?len\\s*?;/g).length == 1, 'message: Your code should set the terminal condition of the loop so it stops at the last index.');",
|
||||
"assert(!code.match(/i\\s*?<=\\s*?len;/g), 'message: Your code should fix the terminal condition of the loop so that it stops at 1 before the length.');"
|
||||
{
|
||||
"text": "Your code should set the initial condition of the loop so it starts at the first index.",
|
||||
"testString": "assert(code.match(/i\\s*?=\\s*?0\\s*?;/g).length == 1, 'Your code should set the initial condition of the loop so it starts at the first index.');"
|
||||
},
|
||||
{
|
||||
"text": "Your code should fix the initial condition of the loop so that the index starts at 0.",
|
||||
"testString": "assert(!code.match(/i\\s?=\\s*?1\\s*?;/g), 'Your code should fix the initial condition of the loop so that the index starts at 0.');"
|
||||
},
|
||||
{
|
||||
"text": "Your code should set the terminal condition of the loop so it stops at the last index.",
|
||||
"testString": "assert(code.match(/i\\s*?<\\s*?len\\s*?;/g).length == 1, 'Your code should set the terminal condition of the loop so it stops at the last index.');"
|
||||
},
|
||||
{
|
||||
"text": "Your code should fix the terminal condition of the loop so that it stops at 1 before the length.",
|
||||
"testString": "assert(!code.match(/i\\s*?<=\\s*?len;/g), 'Your code should fix the terminal condition of the loop so that it stops at 1 before the length.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"function countToFive() {",
|
||||
" let firstFive = \"12345\";",
|
||||
" let len = firstFive.length;",
|
||||
" // Fix the line below",
|
||||
" for (let i = 1; i <= len; i++) {",
|
||||
" // Do not alter code below this line",
|
||||
" console.log(firstFive[i]);",
|
||||
" }",
|
||||
"}",
|
||||
"",
|
||||
"countToFive();"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b86367417b2b2512b3c",
|
||||
@ -360,38 +497,56 @@
|
||||
"<hr>",
|
||||
"The following function is supposed to create a two-dimensional array with <code>m</code> rows and <code>n</code> columns of zeroes. Unfortunately, it's not producing the expected output because the <code>row</code> variable isn't being reinitialized (set back to an empty array) in the outer loop. Fix the code so it returns a correct 3x2 array of zeroes, which looks like <code>[[0, 0], [0, 0], [0, 0]]</code>."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function zeroArray(m, n) {",
|
||||
" // Creates a 2-D array with m rows and n columns of zeroes",
|
||||
" let newArray = [];",
|
||||
" let row = [];",
|
||||
" for (let i = 0; i < m; i++) {",
|
||||
" // Adds the m-th row into newArray",
|
||||
" ",
|
||||
" for (let j = 0; j < n; j++) {",
|
||||
" // Pushes n zeroes into the current row to create the columns",
|
||||
" row.push(0);",
|
||||
" }",
|
||||
" // Pushes the current row, which now has n zeroes in it, to the array",
|
||||
" newArray.push(row);",
|
||||
" }",
|
||||
" return newArray;",
|
||||
"}",
|
||||
"",
|
||||
"let matrix = zeroArray(3, 2);",
|
||||
"console.log(matrix);"
|
||||
],
|
||||
"tests": [
|
||||
"assert(JSON.stringify(matrix) == \"[[0,0],[0,0],[0,0]]\", 'message: Your code should set the <code>matrix</code> variable to an array holding 3 rows of 2 columns of zeroes each.');",
|
||||
"assert(matrix.length == 3, 'message: The <code>matrix</code> variable should have 3 rows.');",
|
||||
"assert(matrix[0].length == 2 && matrix[1].length === 2 && matrix[2].length === 2, 'message: The <code>matrix</code> variable should have 2 columns in each row.');"
|
||||
{
|
||||
"text": "Your code should set the <code>matrix</code> variable to an array holding 3 rows of 2 columns of zeroes each.",
|
||||
"testString": "assert(JSON.stringify(matrix) == \"[[0,0],[0,0],[0,0]]\", 'Your code should set the <code>matrix</code> variable to an array holding 3 rows of 2 columns of zeroes each.');"
|
||||
},
|
||||
{
|
||||
"text": "The <code>matrix</code> variable should have 3 rows.",
|
||||
"testString": "assert(matrix.length == 3, 'The <code>matrix</code> variable should have 3 rows.');"
|
||||
},
|
||||
{
|
||||
"text": "The <code>matrix</code> variable should have 2 columns in each row.",
|
||||
"testString": "assert(matrix[0].length == 2 && matrix[1].length === 2 && matrix[2].length === 2, 'The <code>matrix</code> variable should have 2 columns in each row.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"function zeroArray(m, n) {",
|
||||
" // Creates a 2-D array with m rows and n columns of zeroes",
|
||||
" let newArray = [];",
|
||||
" let row = [];",
|
||||
" for (let i = 0; i < m; i++) {",
|
||||
" // Adds the m-th row into newArray",
|
||||
" ",
|
||||
" for (let j = 0; j < n; j++) {",
|
||||
" // Pushes n zeroes into the current row to create the columns",
|
||||
" row.push(0);",
|
||||
" }",
|
||||
" // Pushes the current row, which now has n zeroes in it, to the array",
|
||||
" newArray.push(row);",
|
||||
" }",
|
||||
" return newArray;",
|
||||
"}",
|
||||
"",
|
||||
"let matrix = zeroArray(3, 2);",
|
||||
"console.log(matrix);"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "587d7b86367417b2b2512b3d",
|
||||
@ -404,23 +559,38 @@
|
||||
"<hr>",
|
||||
"The <code>myFunc()</code> function contains an infinite loop because the terminal condition <code>i != 4</code> will never evaluate to <code>false</code> (and break the looping) - <code>i</code> will increment by 2 each pass, and jump right over 4 since <code>i</code> is odd to start. Fix the comparison operator in the terminal condition so the loop only runs for <code>i</code> less than or equal to 4."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function myFunc() {",
|
||||
" for (let i = 1; i != 4; i += 2) {",
|
||||
" console.log(\"Still going!\");",
|
||||
" }",
|
||||
"}"
|
||||
],
|
||||
"tests": [
|
||||
"assert(code.match(/i\\s*?<=\\s*?4;/g).length == 1, 'message: Your code should change the comparison operator in the terminal condition (the middle part) of the <code>for</code> loop.');",
|
||||
"assert(!code.match(/i\\s*?!=\\s*?4;/g), 'message: Your code should fix the comparison operator in the terminal condition of the loop.');"
|
||||
{
|
||||
"text": "Your code should change the comparison operator in the terminal condition (the middle part) of the <code>for</code> loop.",
|
||||
"testString": "assert(code.match(/i\\s*?<=\\s*?4;/g).length == 1, 'Your code should change the comparison operator in the terminal condition (the middle part) of the <code>for</code> loop.');"
|
||||
},
|
||||
{
|
||||
"text": "Your code should fix the comparison operator in the terminal condition of the loop.",
|
||||
"testString": "assert(!code.match(/i\\s*?!=\\s*?4;/g), 'Your code should fix the comparison operator in the terminal condition of the loop.');"
|
||||
}
|
||||
],
|
||||
"solutions": [],
|
||||
"hints": [],
|
||||
"type": "waypoint",
|
||||
"releasedOn": "Feb 17, 2017",
|
||||
"challengeType": 1,
|
||||
"translations": {}
|
||||
"translations": {},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"function myFunc() {",
|
||||
" for (let i = 1; i != 4; i += 2) {",
|
||||
" console.log(\"Still going!\");",
|
||||
" }",
|
||||
"}"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -15,30 +15,59 @@
|
||||
"We'll also pass strings with special symbols, such as <code>\"2A3*3a2\"</code>, <code>\"2A3 3a2\"</code>, and <code>\"2_A3*3#A2\"</code>.",
|
||||
"Remember to use <a href=\"http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function palindrome(str) {",
|
||||
" // Good luck!",
|
||||
" return true;",
|
||||
"}",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"palindrome(\"eye\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(typeof palindrome(\"eye\") === \"boolean\", 'message: <code>palindrome(\"eye\")</code> should return a boolean.');",
|
||||
"assert(palindrome(\"eye\") === true, 'message: <code>palindrome(\"eye\")</code> should return true.');",
|
||||
"assert(palindrome(\"_eye\") === true, 'message: <code>palindrome(\"_eye\")</code> should return true.');",
|
||||
"assert(palindrome(\"race car\") === true, 'message: <code>palindrome(\"race car\")</code> should return true.');",
|
||||
"assert(palindrome(\"not a palindrome\") === false, 'message: <code>palindrome(\"not a palindrome\")</code> should return false.');",
|
||||
"assert(palindrome(\"A man, a plan, a canal. Panama\") === true, 'message: <code>palindrome(\"A man, a plan, a canal. Panama\")</code> should return true.');",
|
||||
"assert(palindrome(\"never odd or even\") === true, 'message: <code>palindrome(\"never odd or even\")</code> should return true.');",
|
||||
"assert(palindrome(\"nope\") === false, 'message: <code>palindrome(\"nope\")</code> should return false.');",
|
||||
"assert(palindrome(\"almostomla\") === false, 'message: <code>palindrome(\"almostomla\")</code> should return false.');",
|
||||
"assert(palindrome(\"My age is 0, 0 si ega ym.\") === true, 'message: <code>palindrome(\"My age is 0, 0 si ega ym.\")</code> should return true.');",
|
||||
"assert(palindrome(\"1 eye for of 1 eye.\") === false, 'message: <code>palindrome(\"1 eye for of 1 eye.\")</code> should return false.');",
|
||||
"assert(palindrome(\"0_0 (: /-\\ :) 0-0\") === true, 'message: <code>palindrome(\"0_0 (: /-\\ :) 0-0\")</code> should return true.');",
|
||||
"assert(palindrome(\"five|\\_/|four\") === false, 'message: <code>palindrome(\"five|\\_/|four\")</code> should return false.');"
|
||||
{
|
||||
"text": "<code>palindrome(\"eye\")</code> should return a boolean.",
|
||||
"testString": "assert(typeof palindrome(\"eye\") === \"boolean\", '<code>palindrome(\"eye\")</code> should return a boolean.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"eye\")</code> should return true.",
|
||||
"testString": "assert(palindrome(\"eye\") === true, '<code>palindrome(\"eye\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"_eye\")</code> should return true.",
|
||||
"testString": "assert(palindrome(\"_eye\") === true, '<code>palindrome(\"_eye\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"race car\")</code> should return true.",
|
||||
"testString": "assert(palindrome(\"race car\") === true, '<code>palindrome(\"race car\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"not a palindrome\")</code> should return false.",
|
||||
"testString": "assert(palindrome(\"not a palindrome\") === false, '<code>palindrome(\"not a palindrome\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"A man, a plan, a canal. Panama\")</code> should return true.",
|
||||
"testString": "assert(palindrome(\"A man, a plan, a canal. Panama\") === true, '<code>palindrome(\"A man, a plan, a canal. Panama\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"never odd or even\")</code> should return true.",
|
||||
"testString": "assert(palindrome(\"never odd or even\") === true, '<code>palindrome(\"never odd or even\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"nope\")</code> should return false.",
|
||||
"testString": "assert(palindrome(\"nope\") === false, '<code>palindrome(\"nope\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"almostomla\")</code> should return false.",
|
||||
"testString": "assert(palindrome(\"almostomla\") === false, '<code>palindrome(\"almostomla\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"My age is 0, 0 si ega ym.\")</code> should return true.",
|
||||
"testString": "assert(palindrome(\"My age is 0, 0 si ega ym.\") === true, '<code>palindrome(\"My age is 0, 0 si ega ym.\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"1 eye for of 1 eye.\")</code> should return false.",
|
||||
"testString": "assert(palindrome(\"1 eye for of 1 eye.\") === false, '<code>palindrome(\"1 eye for of 1 eye.\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"0_0 (: /-\\ :) 0-0\")</code> should return true.",
|
||||
"testString": "assert(palindrome(\"0_0 (: /-\\ :) 0-0\") === true, '<code>palindrome(\"0_0 (: /-\\ :) 0-0\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>palindrome(\"five|\\_/|four\")</code> should return false.",
|
||||
"testString": "assert(palindrome(\"five|\\_/|four\") === false, '<code>palindrome(\"five|\\_/|four\")</code> should return false.');"
|
||||
}
|
||||
],
|
||||
"type": "bonfire",
|
||||
"isRequired": true,
|
||||
@ -73,6 +102,25 @@
|
||||
"Lembre-se de usar <a href=\"http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"function palindrome(str) {",
|
||||
" // Good luck!",
|
||||
" return true;",
|
||||
"}",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"palindrome(\"eye\");"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -83,43 +131,114 @@
|
||||
"All <a href=\"http://www.mathsisfun.com/roman-numerals.html\" target=\"_blank\">roman numerals</a> answers should be provided in upper-case.",
|
||||
"Remember to use <a href='http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Read-Search-Ask</a> if you get stuck. Try to pair program. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function convertToRoman(num) {",
|
||||
" return num;",
|
||||
"}",
|
||||
"",
|
||||
"convertToRoman(36);"
|
||||
],
|
||||
"solutions": [
|
||||
"function convertToRoman(num) {\n var ref = [['M', 1000], ['CM', 900], ['D', 500], ['CD', 400], ['C', 100], ['XC', 90], ['L', 50], ['XL', 40], ['X', 10], ['IX', 9], ['V', 5], ['IV', 4], ['I', 1]];\n var res = [];\n ref.forEach(function(p) {\n while (num >= p[1]) {\n res.push(p[0]);\n num -= p[1];\n }\n });\n return res.join('');\n}"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(convertToRoman(2), \"II\", 'message: <code>convertToRoman(2)</code> should return \"II\".');",
|
||||
"assert.deepEqual(convertToRoman(3), \"III\", 'message: <code>convertToRoman(3)</code> should return \"III\".');",
|
||||
"assert.deepEqual(convertToRoman(4), \"IV\", 'message: <code>convertToRoman(4)</code> should return \"IV\".');",
|
||||
"assert.deepEqual(convertToRoman(5), \"V\", 'message: <code>convertToRoman(5)</code> should return \"V\".');",
|
||||
"assert.deepEqual(convertToRoman(9), \"IX\", 'message: <code>convertToRoman(9)</code> should return \"IX\".');",
|
||||
"assert.deepEqual(convertToRoman(12), \"XII\", 'message: <code>convertToRoman(12)</code> should return \"XII\".');",
|
||||
"assert.deepEqual(convertToRoman(16), \"XVI\", 'message: <code>convertToRoman(16)</code> should return \"XVI\".');",
|
||||
"assert.deepEqual(convertToRoman(29), \"XXIX\", 'message: <code>convertToRoman(29)</code> should return \"XXIX\".');",
|
||||
"assert.deepEqual(convertToRoman(44), \"XLIV\", 'message: <code>convertToRoman(44)</code> should return \"XLIV\".');",
|
||||
"assert.deepEqual(convertToRoman(45), \"XLV\", 'message: <code>convertToRoman(45)</code> should return \"XLV\"');",
|
||||
"assert.deepEqual(convertToRoman(68), \"LXVIII\", 'message: <code>convertToRoman(68)</code> should return \"LXVIII\"');",
|
||||
"assert.deepEqual(convertToRoman(83), \"LXXXIII\", 'message: <code>convertToRoman(83)</code> should return \"LXXXIII\"');",
|
||||
"assert.deepEqual(convertToRoman(97), \"XCVII\", 'message: <code>convertToRoman(97)</code> should return \"XCVII\"');",
|
||||
"assert.deepEqual(convertToRoman(99), \"XCIX\", 'message: <code>convertToRoman(99)</code> should return \"XCIX\"');",
|
||||
"assert.deepEqual(convertToRoman(400), \"CD\", 'message: <code>convertToRoman(400)</code> should return \"CD\"');",
|
||||
"assert.deepEqual(convertToRoman(500), \"D\", 'message: <code>convertToRoman(500)</code> should return \"D\"');",
|
||||
"assert.deepEqual(convertToRoman(501), \"DI\", 'message: <code>convertToRoman(501)</code> should return \"DI\"');",
|
||||
"assert.deepEqual(convertToRoman(649), \"DCXLIX\", 'message: <code>convertToRoman(649)</code> should return \"DCXLIX\"');",
|
||||
"assert.deepEqual(convertToRoman(798), \"DCCXCVIII\", 'message: <code>convertToRoman(798)</code> should return \"DCCXCVIII\"');",
|
||||
"assert.deepEqual(convertToRoman(891), \"DCCCXCI\", 'message: <code>convertToRoman(891)</code> should return \"DCCCXCI\"');",
|
||||
"assert.deepEqual(convertToRoman(1000), \"M\", 'message: <code>convertToRoman(1000)</code> should return \"M\"');",
|
||||
"assert.deepEqual(convertToRoman(1004), \"MIV\", 'message: <code>convertToRoman(1004)</code> should return \"MIV\"');",
|
||||
"assert.deepEqual(convertToRoman(1006), \"MVI\", 'message: <code>convertToRoman(1006)</code> should return \"MVI\"');",
|
||||
"assert.deepEqual(convertToRoman(1023), \"MXXIII\", 'message: <code>convertToRoman(1023)</code> should return \"MXXIII\"');",
|
||||
"assert.deepEqual(convertToRoman(2014), \"MMXIV\", 'message: <code>convertToRoman(2014)</code> should return \"MMXIV\"');",
|
||||
"assert.deepEqual(convertToRoman(3999), \"MMMCMXCIX\", 'message: <code>convertToRoman(3999)</code> should return \"MMMCMXCIX\"');"
|
||||
{
|
||||
"text": "<code>convertToRoman(2)</code> should return \"II\".",
|
||||
"testString": "assert.deepEqual(convertToRoman(2), \"II\", '<code>convertToRoman(2)</code> should return \"II\".');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(3)</code> should return \"III\".",
|
||||
"testString": "assert.deepEqual(convertToRoman(3), \"III\", '<code>convertToRoman(3)</code> should return \"III\".');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(4)</code> should return \"IV\".",
|
||||
"testString": "assert.deepEqual(convertToRoman(4), \"IV\", '<code>convertToRoman(4)</code> should return \"IV\".');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(5)</code> should return \"V\".",
|
||||
"testString": "assert.deepEqual(convertToRoman(5), \"V\", '<code>convertToRoman(5)</code> should return \"V\".');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(9)</code> should return \"IX\".",
|
||||
"testString": "assert.deepEqual(convertToRoman(9), \"IX\", '<code>convertToRoman(9)</code> should return \"IX\".');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(12)</code> should return \"XII\".",
|
||||
"testString": "assert.deepEqual(convertToRoman(12), \"XII\", '<code>convertToRoman(12)</code> should return \"XII\".');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(16)</code> should return \"XVI\".",
|
||||
"testString": "assert.deepEqual(convertToRoman(16), \"XVI\", '<code>convertToRoman(16)</code> should return \"XVI\".');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(29)</code> should return \"XXIX\".",
|
||||
"testString": "assert.deepEqual(convertToRoman(29), \"XXIX\", '<code>convertToRoman(29)</code> should return \"XXIX\".');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(44)</code> should return \"XLIV\".",
|
||||
"testString": "assert.deepEqual(convertToRoman(44), \"XLIV\", '<code>convertToRoman(44)</code> should return \"XLIV\".');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(45)</code> should return \"XLV\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(45), \"XLV\", '<code>convertToRoman(45)</code> should return \"XLV\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(68)</code> should return \"LXVIII\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(68), \"LXVIII\", '<code>convertToRoman(68)</code> should return \"LXVIII\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(83)</code> should return \"LXXXIII\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(83), \"LXXXIII\", '<code>convertToRoman(83)</code> should return \"LXXXIII\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(97)</code> should return \"XCVII\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(97), \"XCVII\", '<code>convertToRoman(97)</code> should return \"XCVII\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(99)</code> should return \"XCIX\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(99), \"XCIX\", '<code>convertToRoman(99)</code> should return \"XCIX\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(400)</code> should return \"CD\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(400), \"CD\", '<code>convertToRoman(400)</code> should return \"CD\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(500)</code> should return \"D\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(500), \"D\", '<code>convertToRoman(500)</code> should return \"D\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(501)</code> should return \"DI\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(501), \"DI\", '<code>convertToRoman(501)</code> should return \"DI\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(649)</code> should return \"DCXLIX\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(649), \"DCXLIX\", '<code>convertToRoman(649)</code> should return \"DCXLIX\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(798)</code> should return \"DCCXCVIII\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(798), \"DCCXCVIII\", '<code>convertToRoman(798)</code> should return \"DCCXCVIII\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(891)</code> should return \"DCCCXCI\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(891), \"DCCCXCI\", '<code>convertToRoman(891)</code> should return \"DCCCXCI\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(1000)</code> should return \"M\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(1000), \"M\", '<code>convertToRoman(1000)</code> should return \"M\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(1004)</code> should return \"MIV\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(1004), \"MIV\", '<code>convertToRoman(1004)</code> should return \"MIV\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(1006)</code> should return \"MVI\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(1006), \"MVI\", '<code>convertToRoman(1006)</code> should return \"MVI\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(1023)</code> should return \"MXXIII\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(1023), \"MXXIII\", '<code>convertToRoman(1023)</code> should return \"MXXIII\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(2014)</code> should return \"MMXIV\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(2014), \"MMXIV\", '<code>convertToRoman(2014)</code> should return \"MMXIV\"');"
|
||||
},
|
||||
{
|
||||
"text": "<code>convertToRoman(3999)</code> should return \"MMMCMXCIX\"",
|
||||
"testString": "assert.deepEqual(convertToRoman(3999), \"MMMCMXCIX\", '<code>convertToRoman(3999)</code> should return \"MMMCMXCIX\"');"
|
||||
}
|
||||
],
|
||||
"type": "bonfire",
|
||||
"MDNlinks": [
|
||||
@ -147,6 +266,22 @@
|
||||
"N'oublie pas d'utiliser <a href='http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Lire-Chercher-Demander</a> si tu es bloqué. Essaye de trouver un partenaire. Écris ton propre code."
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"function convertToRoman(num) {",
|
||||
" return num;",
|
||||
"}",
|
||||
"",
|
||||
"convertToRoman(36);"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -159,24 +294,26 @@
|
||||
"All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.",
|
||||
"Remember to use <a href='http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Read-Search-Ask</a> if you get stuck. Try to pair program. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function rot13(str) { // LBH QVQ VG!",
|
||||
" ",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"// Change the inputs below to test",
|
||||
"rot13(\"SERR PBQR PNZC\");"
|
||||
],
|
||||
"tail": [],
|
||||
"solutions": [
|
||||
"var lookup = {\n 'A': 'N','B': 'O','C': 'P','D': 'Q',\n 'E': 'R','F': 'S','G': 'T','H': 'U',\n 'I': 'V','J': 'W','K': 'X','L': 'Y',\n 'M': 'Z','N': 'A','O': 'B','P': 'C',\n 'Q': 'D','R': 'E','S': 'F','T': 'G',\n 'U': 'H','V': 'I','W': 'J','X': 'K',\n 'Y': 'L','Z': 'M' \n};\n\nfunction rot13(encodedStr) {\n var codeArr = encodedStr.split(\"\"); // String to Array\n var decodedArr = []; // Your Result goes here\n // Only change code below this line\n \n decodedArr = codeArr.map(function(letter) {\n if(lookup.hasOwnProperty(letter)) {\n letter = lookup[letter];\n }\n return letter;\n });\n\n // Only change code above this line\n return decodedArr.join(\"\"); // Array to String\n}"
|
||||
],
|
||||
"tests": [
|
||||
"assert(rot13(\"SERR PBQR PNZC\") === \"FREE CODE CAMP\", 'message: <code>rot13(\"SERR PBQR PNZC\")</code> should decode to <code>FREE CODE CAMP</code>');",
|
||||
"assert(rot13(\"SERR CVMMN!\") === \"FREE PIZZA!\", 'message: <code>rot13(\"SERR CVMMN!\")</code> should decode to <code>FREE PIZZA!</code>');",
|
||||
"assert(rot13(\"SERR YBIR?\") === \"FREE LOVE?\", 'message: <code>rot13(\"SERR YBIR?\")</code> should decode to <code>FREE LOVE?</code>');",
|
||||
"assert(rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\") === \"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.\", 'message: <code>rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")</code> should decode to <code>THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.</code>');"
|
||||
{
|
||||
"text": "<code>rot13(\"SERR PBQR PNZC\")</code> should decode to <code>FREE CODE CAMP</code>",
|
||||
"testString": "assert(rot13(\"SERR PBQR PNZC\") === \"FREE CODE CAMP\", '<code>rot13(\"SERR PBQR PNZC\")</code> should decode to <code>FREE CODE CAMP</code>');"
|
||||
},
|
||||
{
|
||||
"text": "<code>rot13(\"SERR CVMMN!\")</code> should decode to <code>FREE PIZZA!</code>",
|
||||
"testString": "assert(rot13(\"SERR CVMMN!\") === \"FREE PIZZA!\", '<code>rot13(\"SERR CVMMN!\")</code> should decode to <code>FREE PIZZA!</code>');"
|
||||
},
|
||||
{
|
||||
"text": "<code>rot13(\"SERR YBIR?\")</code> should decode to <code>FREE LOVE?</code>",
|
||||
"testString": "assert(rot13(\"SERR YBIR?\") === \"FREE LOVE?\", '<code>rot13(\"SERR YBIR?\")</code> should decode to <code>FREE LOVE?</code>');"
|
||||
},
|
||||
{
|
||||
"text": "<code>rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")</code> should decode to <code>THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.</code>",
|
||||
"testString": "assert(rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\") === \"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.\", '<code>rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")</code> should decode to <code>THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.</code>');"
|
||||
}
|
||||
],
|
||||
"type": "bonfire",
|
||||
"MDNlinks": [
|
||||
@ -207,6 +344,24 @@
|
||||
"Lembre-se de usar <a href=\"http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"function rot13(str) { // LBH QVQ VG!",
|
||||
" ",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"// Change the inputs below to test",
|
||||
"rot13(\"SERR PBQR PNZC\");"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -219,45 +374,118 @@
|
||||
"For this challenge you will be presented with a string such as <code>800-692-7753</code> or <code>8oo-six427676;laskdjf</code>. Your job is to validate or reject the US phone number based on any combination of the formats provided above. The area code is required. If the country code is provided, you must confirm that the country code is <code>1</code>. Return <code>true</code> if the string is a valid US phone number; otherwise return <code>false</code>.",
|
||||
"Remember to use <a href='http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Read-Search-Ask</a> if you get stuck. Try to pair program. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function telephoneCheck(str) {",
|
||||
" // Good luck!",
|
||||
" return true;",
|
||||
"}",
|
||||
"",
|
||||
"telephoneCheck(\"555-555-5555\");"
|
||||
],
|
||||
"solutions": [
|
||||
"var re = /^([+]?1[\\s]?)?((?:[(](?:[2-9]1[02-9]|[2-9][02-8][0-9])[)][\\s]?)|(?:(?:[2-9]1[02-9]|[2-9][02-8][0-9])[\\s.-]?)){1}([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2}[\\s.-]?){1}([0-9]{4}){1}$/;\n\nfunction telephoneCheck(str) {\n return re.test(str);\n}\n\ntelephoneCheck(\"555-555-5555\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(typeof telephoneCheck(\"555-555-5555\") === \"boolean\", 'message: <code>telephoneCheck(\"555-555-5555\")</code> should return a boolean.');",
|
||||
"assert(telephoneCheck(\"1 555-555-5555\") === true, 'message: <code>telephoneCheck(\"1 555-555-5555\")</code> should return true.');",
|
||||
"assert(telephoneCheck(\"1 (555) 555-5555\") === true, 'message: <code>telephoneCheck(\"1 (555) 555-5555\")</code> should return true.');",
|
||||
"assert(telephoneCheck(\"5555555555\") === true, 'message: <code>telephoneCheck(\"5555555555\")</code> should return true.');",
|
||||
"assert(telephoneCheck(\"555-555-5555\") === true, 'message: <code>telephoneCheck(\"555-555-5555\")</code> should return true.');",
|
||||
"assert(telephoneCheck(\"(555)555-5555\") === true, 'message: <code>telephoneCheck(\"(555)555-5555\")</code> should return true.');",
|
||||
"assert(telephoneCheck(\"1(555)555-5555\") === true, 'message: <code>telephoneCheck(\"1(555)555-5555\")</code> should return true.');",
|
||||
"assert(telephoneCheck(\"555-5555\") === false, 'message: <code>telephoneCheck(\"555-5555\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"5555555\") === false, 'message: <code>telephoneCheck(\"5555555\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"1 555)555-5555\") === false, 'message: <code>telephoneCheck(\"1 555)555-5555\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"1 555 555 5555\") === true, 'message: <code>telephoneCheck(\"1 555 555 5555\")</code> should return true.');",
|
||||
"assert(telephoneCheck(\"1 456 789 4444\") === true, 'message: <code>telephoneCheck(\"1 456 789 4444\")</code> should return true.');",
|
||||
"assert(telephoneCheck(\"123**&!!asdf#\") === false, 'message: <code>telephoneCheck(\"123**&!!asdf#\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"55555555\") === false, 'message: <code>telephoneCheck(\"55555555\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"(6054756961)\") === false, 'message: <code>telephoneCheck(\"(6054756961)\")</code> should return false');",
|
||||
"assert(telephoneCheck(\"2 (757) 622-7382\") === false, 'message: <code>telephoneCheck(\"2 (757) 622-7382\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"0 (757) 622-7382\") === false, 'message: <code>telephoneCheck(\"0 (757) 622-7382\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"-1 (757) 622-7382\") === false, 'message: <code>telephoneCheck(\"-1 (757) 622-7382\")</code> should return false');",
|
||||
"assert(telephoneCheck(\"2 757 622-7382\") === false, 'message: <code>telephoneCheck(\"2 757 622-7382\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"10 (757) 622-7382\") === false, 'message: <code>telephoneCheck(\"10 (757) 622-7382\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"27576227382\") === false, 'message: <code>telephoneCheck(\"27576227382\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"(275)76227382\") === false, 'message: <code>telephoneCheck(\"(275)76227382\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"2(757)6227382\") === false, 'message: <code>telephoneCheck(\"2(757)6227382\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"2(757)622-7382\") === false, 'message: <code>telephoneCheck(\"2(757)622-7382\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"555)-555-5555\") === false, 'message: <code>telephoneCheck(\"555)-555-5555\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"(555-555-5555\") === false, 'message: <code>telephoneCheck(\"(555-555-5555\")</code> should return false.');",
|
||||
"assert(telephoneCheck(\"(555)5(55?)-5555\") === false, 'message: <code>telephoneCheck(\"(555)5(55?)-5555\")</code> should return false.');"
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"555-555-5555\")</code> should return a boolean.",
|
||||
"testString": "assert(typeof telephoneCheck(\"555-555-5555\") === \"boolean\", '<code>telephoneCheck(\"555-555-5555\")</code> should return a boolean.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"1 555-555-5555\")</code> should return true.",
|
||||
"testString": "assert(telephoneCheck(\"1 555-555-5555\") === true, '<code>telephoneCheck(\"1 555-555-5555\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"1 (555) 555-5555\")</code> should return true.",
|
||||
"testString": "assert(telephoneCheck(\"1 (555) 555-5555\") === true, '<code>telephoneCheck(\"1 (555) 555-5555\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"5555555555\")</code> should return true.",
|
||||
"testString": "assert(telephoneCheck(\"5555555555\") === true, '<code>telephoneCheck(\"5555555555\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"555-555-5555\")</code> should return true.",
|
||||
"testString": "assert(telephoneCheck(\"555-555-5555\") === true, '<code>telephoneCheck(\"555-555-5555\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"(555)555-5555\")</code> should return true.",
|
||||
"testString": "assert(telephoneCheck(\"(555)555-5555\") === true, '<code>telephoneCheck(\"(555)555-5555\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"1(555)555-5555\")</code> should return true.",
|
||||
"testString": "assert(telephoneCheck(\"1(555)555-5555\") === true, '<code>telephoneCheck(\"1(555)555-5555\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"555-5555\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"555-5555\") === false, '<code>telephoneCheck(\"555-5555\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"5555555\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"5555555\") === false, '<code>telephoneCheck(\"5555555\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"1 555)555-5555\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"1 555)555-5555\") === false, '<code>telephoneCheck(\"1 555)555-5555\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"1 555 555 5555\")</code> should return true.",
|
||||
"testString": "assert(telephoneCheck(\"1 555 555 5555\") === true, '<code>telephoneCheck(\"1 555 555 5555\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"1 456 789 4444\")</code> should return true.",
|
||||
"testString": "assert(telephoneCheck(\"1 456 789 4444\") === true, '<code>telephoneCheck(\"1 456 789 4444\")</code> should return true.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"123**&!!asdf#\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"123**&!!asdf#\") === false, '<code>telephoneCheck(\"123**&!!asdf#\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"55555555\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"55555555\") === false, '<code>telephoneCheck(\"55555555\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"(6054756961)\")</code> should return false",
|
||||
"testString": "assert(telephoneCheck(\"(6054756961)\") === false, '<code>telephoneCheck(\"(6054756961)\")</code> should return false');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"2 (757) 622-7382\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"2 (757) 622-7382\") === false, '<code>telephoneCheck(\"2 (757) 622-7382\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"0 (757) 622-7382\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"0 (757) 622-7382\") === false, '<code>telephoneCheck(\"0 (757) 622-7382\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"-1 (757) 622-7382\")</code> should return false",
|
||||
"testString": "assert(telephoneCheck(\"-1 (757) 622-7382\") === false, '<code>telephoneCheck(\"-1 (757) 622-7382\")</code> should return false');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"2 757 622-7382\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"2 757 622-7382\") === false, '<code>telephoneCheck(\"2 757 622-7382\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"10 (757) 622-7382\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"10 (757) 622-7382\") === false, '<code>telephoneCheck(\"10 (757) 622-7382\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"27576227382\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"27576227382\") === false, '<code>telephoneCheck(\"27576227382\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"(275)76227382\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"(275)76227382\") === false, '<code>telephoneCheck(\"(275)76227382\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"2(757)6227382\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"2(757)6227382\") === false, '<code>telephoneCheck(\"2(757)6227382\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"2(757)622-7382\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"2(757)622-7382\") === false, '<code>telephoneCheck(\"2(757)622-7382\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"555)-555-5555\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"555)-555-5555\") === false, '<code>telephoneCheck(\"555)-555-5555\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"(555-555-5555\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"(555-555-5555\") === false, '<code>telephoneCheck(\"(555-555-5555\")</code> should return false.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>telephoneCheck(\"(555)5(55?)-5555\")</code> should return false.",
|
||||
"testString": "assert(telephoneCheck(\"(555)5(55?)-5555\") === false, '<code>telephoneCheck(\"(555)5(55?)-5555\")</code> should return false.');"
|
||||
}
|
||||
],
|
||||
"type": "bonfire",
|
||||
"MDNlinks": [
|
||||
@ -296,6 +524,23 @@
|
||||
"Lembre-se de usar <a href='http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Ler-Procurar-Perguntar</a> se você ficar preso. Tente programar em par. Escreva seu próprio código."
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"function telephoneCheck(str) {",
|
||||
" // Good luck!",
|
||||
" return true;",
|
||||
"}",
|
||||
"",
|
||||
"telephoneCheck(\"555-555-5555\");"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -311,36 +556,34 @@
|
||||
"Remember to use <a href='http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Read-Search-Ask</a> if you get stuck. Try to pair program. Write your own code.",
|
||||
"<table class='table table-striped'><tr><th>Currency Unit</th><th>Amount</th></tr><tr><td>Penny</td><td>$0.01 (PENNY)</td></tr><tr><td>Nickel</td><td>$0.05 (NICKEL)</td></tr><tr><td>Dime</td><td>$0.1 (DIME)</td></tr><tr><td>Quarter</td><td>$0.25 (QUARTER)</td></tr><tr><td>Dollar</td><td>$1 (DOLLAR)</td></tr><tr><td>Five Dollars</td><td>$5 (FIVE)</td></tr><tr><td>Ten Dollars</td><td>$10 (TEN)</td></tr><tr><td>Twenty Dollars</td><td>$20 (TWENTY)</td></tr><tr><td>One-hundred Dollars</td><td>$100 (ONE HUNDRED)</td></tr></table>"
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function checkCashRegister(price, cash, cid) {",
|
||||
" var change;",
|
||||
" // Here is your change, ma'am.",
|
||||
" return change;",
|
||||
"}",
|
||||
"",
|
||||
"// Example cash-in-drawer array:",
|
||||
"// [[\"PENNY\", 1.01],",
|
||||
"// [\"NICKEL\", 2.05],",
|
||||
"// [\"DIME\", 3.1],",
|
||||
"// [\"QUARTER\", 4.25],",
|
||||
"// [\"ONE\", 90],",
|
||||
"// [\"FIVE\", 55],",
|
||||
"// [\"TEN\", 20],",
|
||||
"// [\"TWENTY\", 60],",
|
||||
"// [\"ONE HUNDRED\", 100]]",
|
||||
"",
|
||||
"checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]]);"
|
||||
],
|
||||
"solutions": [
|
||||
"var denom = [\n\t{ name: 'ONE HUNDRED', val: 100},\n\t{ name: 'TWENTY', val: 20},\n\t{ name: 'TEN', val: 10},\n\t{ name: 'FIVE', val: 5},\n\t{ name: 'ONE', val: 1},\n\t{ name: 'QUARTER', val: 0.25},\n\t{ name: 'DIME', val: 0.1},\n\t{ name: 'NICKEL', val: 0.05},\n\t{ name: 'PENNY', val: 0.01}\n];\n\nfunction checkCashRegister(price, cash, cid) {\n var output = {status: null, change: []};\n var change = cash - price;\n var register = cid.reduce(function(acc, curr) {\n acc.total += curr[1];\n acc[curr[0]] = curr[1];\n return acc;\n }, {total: 0});\n if(register.total === change) {\n output.status = 'CLOSED';\n output.change = cid;\n return output;\n }\n if(register.total < change) {\n output.status = 'INSUFFICIENT_FUNDS';\n return output;\n }\n var change_arr = denom.reduce(function(acc, curr) {\n var value = 0;\n while(register[curr.name] > 0 && change >= curr.val) {\n change -= curr.val;\n register[curr.name] -= curr.val;\n value += curr.val;\n change = Math.round(change * 100) / 100;\n }\n if(value > 0) {\n acc.push([ curr.name, value ]);\n }\n return acc;\n }, []);\n if(change_arr.length < 1 || change > 0) {\n output.status = 'INSUFFICIENT_FUNDS';\n return output;\n }\n output.status = 'OPEN';\n output.change = change_arr;\n return output;\n}"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(Object.prototype.toString.call(checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])), '[object Object]', 'message: <code>checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])</code> should return an object.');",
|
||||
"assert.deepEqual(checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]]), {status: \"OPEN\", change: [[\"QUARTER\", 0.5]]}, 'message: <code>checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])</code> should return <code>{status: \"OPEN\", change: [[\"QUARTER\", 0.5]]}</code>.');",
|
||||
"assert.deepEqual(checkCashRegister(3.26, 100, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]]), {status: \"OPEN\", change: [[\"TWENTY\", 60], [\"TEN\", 20], [\"FIVE\", 15], [\"ONE\", 1], [\"QUARTER\", 0.5], [\"DIME\", 0.2], [\"PENNY\", 0.04]]}, 'message: <code>checkCashRegister(3.26, 100, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])</code> should return <code>{status: \"OPEN\", change: [[\"TWENTY\", 60], [\"TEN\", 20], [\"FIVE\", 15], [\"ONE\", 1], [\"QUARTER\", 0.5], [\"DIME\", 0.2], [\"PENNY\", 0.04]]}</code>.');",
|
||||
"assert.deepEqual(checkCashRegister(19.5, 20, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]), {status: \"INSUFFICIENT_FUNDS\", change: []}, 'message: <code>checkCashRegister(19.5, 20, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return <code>{status: \"INSUFFICIENT_FUNDS\", change: []}</code>.');",
|
||||
"assert.deepEqual(checkCashRegister(19.5, 20, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 1], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]), {status: \"INSUFFICIENT_FUNDS\", change: []}, 'message: <code>checkCashRegister(19.5, 20, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 1], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return <code>{status: \"INSUFFICIENT_FUNDS\", change: []}</code>.');",
|
||||
"assert.deepEqual(checkCashRegister(19.5, 20, [[\"PENNY\", 0.5], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]), {status: \"CLOSED\", change: [[\"PENNY\", 0.5], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]}, 'message: <code>checkCashRegister(19.5, 20, [[\"PENNY\", 0.5], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return <code>{status: \"CLOSED\", change: [[\"PENNY\", 0.5], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]}</code>.');"
|
||||
{
|
||||
"text": "<code>checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])</code> should return an object.",
|
||||
"testString": "assert.deepEqual(Object.prototype.toString.call(checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])), '[object Object]', '<code>checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])</code> should return an object.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])</code> should return <code>{status: \"OPEN\", change: [[\"QUARTER\", 0.5]]}</code>.",
|
||||
"testString": "assert.deepEqual(checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]]), {status: \"OPEN\", change: [[\"QUARTER\", 0.5]]}, '<code>checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])</code> should return <code>{status: \"OPEN\", change: [[\"QUARTER\", 0.5]]}</code>.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>checkCashRegister(3.26, 100, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])</code> should return <code>{status: \"OPEN\", change: [[\"TWENTY\", 60], [\"TEN\", 20], [\"FIVE\", 15], [\"ONE\", 1], [\"QUARTER\", 0.5], [\"DIME\", 0.2], [\"PENNY\", 0.04]]}</code>.",
|
||||
"testString": "assert.deepEqual(checkCashRegister(3.26, 100, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]]), {status: \"OPEN\", change: [[\"TWENTY\", 60], [\"TEN\", 20], [\"FIVE\", 15], [\"ONE\", 1], [\"QUARTER\", 0.5], [\"DIME\", 0.2], [\"PENNY\", 0.04]]}, '<code>checkCashRegister(3.26, 100, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]])</code> should return <code>{status: \"OPEN\", change: [[\"TWENTY\", 60], [\"TEN\", 20], [\"FIVE\", 15], [\"ONE\", 1], [\"QUARTER\", 0.5], [\"DIME\", 0.2], [\"PENNY\", 0.04]]}</code>.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>checkCashRegister(19.5, 20, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return <code>{status: \"INSUFFICIENT_FUNDS\", change: []}</code>.",
|
||||
"testString": "assert.deepEqual(checkCashRegister(19.5, 20, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]), {status: \"INSUFFICIENT_FUNDS\", change: []}, '<code>checkCashRegister(19.5, 20, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return <code>{status: \"INSUFFICIENT_FUNDS\", change: []}</code>.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>checkCashRegister(19.5, 20, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 1], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return <code>{status: \"INSUFFICIENT_FUNDS\", change: []}</code>.",
|
||||
"testString": "assert.deepEqual(checkCashRegister(19.5, 20, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 1], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]), {status: \"INSUFFICIENT_FUNDS\", change: []}, '<code>checkCashRegister(19.5, 20, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 1], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return <code>{status: \"INSUFFICIENT_FUNDS\", change: []}</code>.');"
|
||||
},
|
||||
{
|
||||
"text": "<code>checkCashRegister(19.5, 20, [[\"PENNY\", 0.5], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return <code>{status: \"CLOSED\", change: [[\"PENNY\", 0.5], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]}</code>.",
|
||||
"testString": "assert.deepEqual(checkCashRegister(19.5, 20, [[\"PENNY\", 0.5], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]), {status: \"CLOSED\", change: [[\"PENNY\", 0.5], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]}, '<code>checkCashRegister(19.5, 20, [[\"PENNY\", 0.5], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return <code>{status: \"CLOSED\", change: [[\"PENNY\", 0.5], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]}</code>.');"
|
||||
}
|
||||
],
|
||||
"type": "bonfire",
|
||||
"isRequired": true,
|
||||
@ -381,6 +624,35 @@
|
||||
"<table class='table table-striped'><tr><th>Currency Unit</th><th>Amount</th></tr><tr><td>Penny</td><td>$0.01 (PENNY)</td></tr><tr><td>Nickel</td><td>$0.05 (NICKEL)</td></tr><tr><td>Dime</td><td>$0.1 (DIME)</td></tr><tr><td>Quarter</td><td>$0.25 (QUARTER)</td></tr><tr><td>Dollar</td><td>$1 (DOLLAR)</td></tr><tr><td>Five Dollars</td><td>$5 (FIVE)</td></tr><tr><td>Ten Dollars</td><td>$10 (TEN)</td></tr><tr><td>Twenty Dollars</td><td>$20 (TWENTY)</td></tr><tr><td>One-hundred Dollars</td><td>$100 (ONE HUNDRED)</td></tr></table>"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
"indexjs": {
|
||||
"key": "indexjs",
|
||||
"ext": "js",
|
||||
"name": "index",
|
||||
"contents": [
|
||||
"function checkCashRegister(price, cash, cid) {",
|
||||
" var change;",
|
||||
" // Here is your change, ma'am.",
|
||||
" return change;",
|
||||
"}",
|
||||
"",
|
||||
"// Example cash-in-drawer array:",
|
||||
"// [[\"PENNY\", 1.01],",
|
||||
"// [\"NICKEL\", 2.05],",
|
||||
"// [\"DIME\", 3.1],",
|
||||
"// [\"QUARTER\", 4.25],",
|
||||
"// [\"ONE\", 90],",
|
||||
"// [\"FIVE\", 55],",
|
||||
"// [\"TEN\", 20],",
|
||||
"// [\"TWENTY\", 60],",
|
||||
"// [\"ONE HUNDRED\", 100]]",
|
||||
"",
|
||||
"checkCashRegister(19.5, 20, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.1], [\"QUARTER\", 4.25], [\"ONE\", 90], [\"FIVE\", 55], [\"TEN\", 20], [\"TWENTY\", 60], [\"ONE HUNDRED\", 100]]);"
|
||||
],
|
||||
"head": [],
|
||||
"tail": []
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user