From 655c7eef52399dec43fbc5b336396beefc7c24ef Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Sun, 5 Jul 2015 17:03:41 -0700 Subject: [PATCH 01/13] clear basic-javascript.json --- seed/challenges/basic-javascript.json | 233 -------------------------- 1 file changed, 233 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index b8ae5cbaa1..e69de29bb2 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1,233 +0,0 @@ -{ - "name": "Basic JavaScript", - "order": 0.006, - "challenges": [ - { - "id": "bd7129d8c441eddfaeb5bdef", - "name": "Waypoint: Build an Adventure Game", - "dashedName": "waypoint-build-an-adventure-game", - "difficulty": 0.24, - "challengeSeed": ["114604814"], - "description": [ - "Now that you understand some Computer Science fundamentals, let's focus on programming JavaScript!", - "We're going to work through Codecademy's famous interactive JavaScript course.", - "This course will teach us some JavaScript fundamentals while guiding us through the process of building interesting web apps, all within Codecademy's learner-friendly environment!", - "Go to http://www.codecademy.com/courses/getting-started-v2/0/1 and complete the section.", - "Be sure to also complete this section: http://www.codecademy.com/courses/javascript-beginner-en-x9DnD/0/1." - ], - "challengeType": 2, - "tests": [], - "nameCn": "", - "descriptionCn": [], - "nameFr": "", - "descriptionFr": [], - "nameRu": "", - "descriptionRu": [], - "nameEs": "", - "descriptionEs": [], - "namePt": "", - "descriptionPt": [] - }, - { - "id": "bd7130d8c441eddfaeb5bdef", - "name": "Waypoint: Build Rock Paper Scissors", - "dashedName": "waypoint-build-rock-paper-scissors", - "difficulty": 0.25, - "challengeSeed": ["114604815"], - "description": [ - "Now we'll learn how JavaScript functions work, and use them to build a simple Rock Paper Scissors game.", - "Go to http://www.codecademy.com/courses/javascript-beginner-en-6LzGd/0/1 and complete the section.", - "Be sure to also complete this section: http://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/1." - ], - "challengeType": 2, - "tests": [], - "nameCn": "", - "descriptionCn": [], - "nameFr": "", - "descriptionFr": [], - "nameRu": "", - "descriptionRu": [], - "nameEs": "", - "descriptionEs": [], - "namePt": "", - "descriptionPt": [] - }, - { - "id": "bd7131d8c441eddfaeb5bdef", - "name": "Waypoint: Learn JavaScript For Loops", - "dashedName": "waypoint-learn-javascript-for-loops", - "difficulty": 0.26, - "challengeSeed": ["114614220"], - "description": [ - "Let's learn more about the loops that make virtually all programs possible - the \"For Loop\" and \"While Loop\". First, we'll learn the For Loop.", - "Go to http://www.codecademy.com/courses/javascript-beginner-en-NhsaT/0/1web and complete the section.", - "Be sure to also complete this section: http://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/1." - ], - "challengeType": 2, - "tests": [], - "nameCn": "", - "descriptionCn": [], - "nameFr": "", - "descriptionFr": [], - "nameRu": "", - "descriptionRu": [], - "nameEs": "", - "descriptionEs": [], - "namePt": "", - "descriptionPt": [] - }, - { - "id": "bd7132d8c441eddfaeb5bdef", - "name": "Waypoint: Learn JavaScript While Loops", - "dashedName": "waypoint-learn-javascript-while-loops", - "difficulty": 0.27, - "challengeSeed": ["114612889"], - "description": [ - "Go to http://www.codecademy.com/courses/javascript-beginner-en-ASGIv/0/1 and complete the section.", - "Be sure to also complete this section: http://www.codecademy.com/courses/javascript-beginner-en-mrTNH-6VIZ9/0/1." - ], - "challengeType": 2, - "tests": [], - "nameCn": "", - "descriptionCn": [], - "nameFr": "", - "descriptionFr": [], - "nameRu": "", - "descriptionRu": [], - "nameEs": "", - "descriptionEs": [], - "namePt": "", - "descriptionPt": [] - }, - { - "id": "bd7133d8c441eddfaeb5bdef", - "name": "Waypoint: Learn Control Flow", - "dashedName": "waypoint-learn-control-flow", - "difficulty": 0.28, - "challengeSeed": ["114612888"], - "description": [ - "Much of human reasoning can be broken down into what we call Boolean Logic. Lucky for us, computers can think the same way! Let's learn how to instruct our computers by writing \"If Statements\" and \"Else Statements\".", - "We'll also learn some advanced \"Control Flow\" principals, such as ways we can exit loops early.", - "Go to http://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/1 and complete the section.", - "Be sure to also complete this section: http://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/1." - ], - "challengeType": 2, - "tests": [], - "nameCn": "", - "descriptionCn": [], - "nameFr": "", - "descriptionFr": [], - "nameRu": "", - "descriptionRu": [], - "nameEs": "", - "descriptionEs": [], - "namePt": "", - "descriptionPt": [] - }, - { - "id": "bd7134d8c441eddfaeb5bdef", - "name": "Waypoint: Build a Contact List", - "dashedName": "waypoint-build-a-contact-list", - "difficulty": 0.29, - "challengeSeed": ["114612887"], - "description": [ - "Up to this point, you've been working mostly with strings and numbers. Now we're going to learn more complicated data structures, like \"Arrays\" and \"Objects\".", - "Go to http://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/0/1 and complete the section.", - "Be sure to also complete this section: http://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/1." - ], - "challengeType": 2, - "tests": [], - "nameCn": "", - "descriptionCn": [], - "nameFr": "", - "descriptionFr": [], - "nameRu": "", - "descriptionRu": [], - "nameEs": "", - "descriptionEs": [], - "namePt": "", - "descriptionPt": [] - }, - { - "id": "bd7135d8c441eddfaeb5bdef", - "name": "Waypoint: Build an Address Book", - "dashedName": "waypoint-build-an-address-book", - "difficulty": 0.30, - "challengeSeed": ["114612885"], - "description": [ - "Let's learn more about objects.", - "Go to http://www.codecademy.com/courses/spencer-sandbox/0/1 and complete the section.", - "Be sure to also complete this section: http://www.codecademy.com/courses/building-an-address-book/0/1?curriculumid=506324b3a7dffd00020bf661." - ], - "challengeType": 2, - "tests": [], - "nameCn": "", - "descriptionCn": [], - "nameFr": "", - "descriptionFr": [], - "nameRu": "", - "descriptionRu": [], - "nameEs": "", - "descriptionEs": [], - "namePt": "", - "descriptionPt": [] - }, - { - "id": "bd7136d8c441eddfaeb5bdef", - "name": "Waypoint: Build a Cash Register", - "dashedName": "waypoint-build-a-cash-register", - "difficulty": 0.31, - "challengeSeed": ["114612882"], - "description": [ - "In this final Codecademy section, we'll learn even more about JavaScript objects.", - "Go to http://www.codecademy.com/courses/objects-ii/0/1 and complete this section.", - "Be sure to also complete the final section: http://www.codecademy.com/courses/close-the-super-makert/0/1." - ], - "challengeType": 2, - "tests": [], - "nameCn": "", - "descriptionCn": [], - "nameFr": "", - "descriptionFr": [], - "nameRu": "", - "descriptionRu": [], - "nameEs": "", - "descriptionEs": [], - "namePt": "", - "descriptionPt": [] - }, - { - "id": "bd7138d8c441eddfaeb5bdef", - "name": "Waypoint: Learn Regular Expressions", - "dashedName": "waypoint-learn-regular-expressions", - "difficulty": 0.33, - "challengeSeed": ["112547802"], - "description": [ - "You can use a Regular Expression, or \"Regex\", to select specific types of characters in text.", - "Check out http://www.regexr.com. It's a Regular Expression Sandbox for experimenting with Regular Expressions.", - "Now go to http://www.regexone.com.", - "Note that you can click \"continue\" to move on to the next step as soon as all the tasks have green check marks beside them. You can often do this just by using the wildcard \"dot\" operator, but try to use the techniques that each lesson recommends.", - "Complete \"Complete the 15-lesson tutorial\"", - "Complete \"Complete Practical Example 1: Matching a scientific or decimal number\"", - "Complete \"Complete Practical Example 2: Matching phone numbers\"", - "Complete \"Complete Practical Example 3: Matching emails\"", - "Complete \"Complete Practical Example 4: Matching HTML\"", - "Complete \"Complete Practical Example 5: Matching specific filenames\"", - "Complete \"Complete Practical Example 6: Trimming whitespace from start and end of line\"", - "Once you've completed these challenges, move on to our next Waypoint." - ], - "challengeType": 2, - "tests": [], - "nameCn": "", - "descriptionCn": [], - "nameFr": "", - "descriptionFr": [], - "nameRu": "", - "descriptionRu": [], - "nameEs": "", - "descriptionEs": [], - "namePt": "", - "descriptionPt": [] - } - ] -} From 3098a6dc60da60eca64c73ef5ed0210fc4d65401 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Sun, 5 Jul 2015 17:12:52 -0700 Subject: [PATCH 02/13] add basic javascript.json --- seed/challenges/basic-javascript.json | 334 ++++++++++++++++++++++++++ 1 file changed, 334 insertions(+) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index e69de29bb2..9a533cfe1c 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -0,0 +1,334 @@ +{ + "name": "Basic JavaScript", + "order": 0.006, + "challenges": [ + { + "_id": "bd7123c9c441eddfaeb5bdef", + "name": "Meet Booleans", + "dashedNname": "waypoint-meet-booleans", + "difficulty": "9.98", + "description": [ + "Return true", + "Some additional directions" + ], + "tests": [ + "expect(welcomeToBooleans()).to.be.a(\"boolean\");", + "expect(welcomeToBooleans()).to.be.true;" + ], + "challengeSeed": [ + "function welcomeToBooleans() {", + "// Good luck!", + "return false;", + "}", + "", + "welcomeToBooleans();" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c442eddfaeb5bdef", + "name": "Define Your Name", + "difficulty": "9.9801", + "description": [ + "Set the value of myName to your name by typing your name in quotes.", + "Currently myName is empty. Type in your name and hit the submit button.", + "Look at the ourName example if you get stuck." + ], + "tests": [ + "expect(myName).to.be.a(\"string\");", + "expect(myName).length.not.to.be(0);" + ], + "challengeSeed": [ + "// ourName = \"Free Code Camp\";", + "myName = \"\";" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c443eddfaeb5bdef", + "name": "Start Using Variables", + "difficulty": "9.9802", + "description": [ + "Now, use the var keyword to create a variable called myName. Set its value to your name.", + "Variables are used to store values.", + "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in camel case. An example of camel case is: camelCase.", + "Look at the ourName example if you get stuck." + ], + "tests": [ + "expect(myName).to.be.a(\"string\");", + "expect(myName).length.not.to.be(0);" + ], + "challengeSeed": [ + "// var ourName = \"Free Code Camp\";", + "" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c444eddfaeb5bdef", + "name": "Define Your First and Last Name", + "difficulty": "9.9803", + "description": [ + "Now, use the var keyword to create a variable called myFirstName and set its value to your first name. Then set a variable called myLastName to your last name.", + "Variables are used to store values.", + "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", + "Look at the ourFirstName and ourLastName examples if you get stuck." + ], + "tests": [ + "expect(myFirstName).to.be.a(\"string\");", + "expect(myFirstName).length.not.to.be(0);", + "expect(myLastName).to.be.a(\"string\");", + "expect(myLastName).length.not.to.be(0);" + ], + "challengeSeed": [ + "// var ourFirstName = \"Free\";", + "// var ourLastName = \"Code Camp\";", + "", + "" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c445eddfaeb5bdef", + "name": "Combine Two Strings into One String", + "difficulty": "9.9804", + "description": [ + "Make a variable called myName by adding the string of your first name to the string of your last name.", + "Strings can be combined in a process called concatenation.", + "Be sure to include a space at the end of your first string. Otherwise the two strings will not have a space between them.", + "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", + "Look at the ourName example if you get stuck." + ], + "tests": [ + "expect(myName).to.be.a(\"string\");", + "expect(myName).length.not.to.be(0);", + "expect((/\\s+/).test(myName)).to.be.true;" + ], + "challengeSeed": [ + "// var ourName = \"Free \" + \"Code Camp\";", + "", + "" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c446eddfaeb5bdef", + "name": "Combine Two Variables into One Variable", + "difficulty": "9.9805", + "description": [ + "Make the variables myFirstName, myLastName, and myFullName. Concatenate my myFirstName to myLastName to create myFullName.", + "Strings can be combined in a process called concatenation.", + "Be sure to include a space at the end of myFirstName. Otherwise myFullName will not contain a space between your first and last names.", + "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", + "Look at the ourFullName example if you get stuck." + ], + "tests": [ + "expect(myFirstName).to.be.a(\"string\");", + "expect(myLastName).to.be.a(\"string\");", + "expect(myFullName).to.be.a(\"string\");", + "expect(myFullName).length.not.to.be(0);", + "expect((/\\s+/).test(myFullName)).to.be.true;" + ], + "challengeSeed": [ + "// var ourFirstName = \"Free \";", + "// var ourLastName = \"Code Camp\";", + "// var ourFullName = ourFirstName + ourLastName;", + "" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c447eddfaeb5bdef", + "name": "Concatenate Both Variables and Strings into the Same Variable", + "difficulty": "9.9806", + "description": [ + "Make the variables myFirstName, myLastName, and myFullName. Concatenate my myFirstName to myLastName to create myFullName, but this time add the space as a separate string, not as part of myFirstName or myLastName.", + "Strings can be combined in a process called concatenation.", + "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", + "Look at the ourFullName example if you get stuck." + ], + "tests": [ + "expect(myFirstName).to.be.a(\"string\");", + "expect(myLastName).to.be.a(\"string\");", + "expect(myFullName).to.be.a(\"string\");", + "expect(myFullName).length.not.to.be(0);", + "expect((/\\s+/).test(myFullName)).to.be.true;" + ], + "challengeSeed": [ + "// var ourFirstName = \"Free\";", + "// var ourLastName = \"Code Camp\";", + "// var ourFullName = ourFirstName + \" \" + ourLastName;", + "" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c448eddfaeb5bdef", + "name": "Check the Length Property of a String Variable", + "difficulty": "9.9809", + "description": [ + "Use the .length property to count the number of characters in the lastNameLength variable.", + "For example, if we created a variable var firstName = \"Julie\", we could find out how long the string \"Julie\" is by using the firstName.length property." + ], + "tests": [ + "expect(lastNameLength).to.equal(4);" + ], + "challengeSeed": [ + "var firstName = \"Madeline\";", + "", + "var firstNameLength = firstName.length;", + "", + "var lastName = \"Chen\";", + "", + "var lastNameLength = lastName;", + "", + "", + "", + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "function returnValue(lastNameLength) {", + " return lastNameLength;", + "}", + "returnValue(lastNameLength);" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c549eddfaeb5bdef", + "name": "Use Bracket Notation to Find the First Character in a String", + "difficulty": "9.9810", + "description": [ + "Use bracket notation to find the first character in a the firstLetterOfLastName variable.", + "Bracket notation is a way to get a character at a specific index within a string.", + "Computers don't start counting at 1 like humans do. They start at 0.", + "For example, the character at index 0 in the word \"Julie\" is \"J\". So if var firstName = \"Julie\", you can get the value of the first letter of the string by using firstName[0].", + "Try looking at the firstLetterOfFirstName variable declaration if you get stuck." + ], + "tests": [ + "expect(firstLetterOfLastName).to.equal('C');" + ], + "challengeSeed": [ + "var firstName = \"Madeline\";", + "", + "var firstLetterOfFirstName = firstName[0];", + "", + "var lastName = \"Chen\";", + "", + "var firstLetterOfLastName = lastName;", + "", + "", + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "function returnValue(firstLetterOfLastName) {", + " return firstLetterOfLastName;", + "}", + "returnValue(firstLetterOfLastName);" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c450eddfaeb5bdef", + "name": "Use Bracket Notation to Find the Nth Character in a String", + "difficulty": "9.9811", + "description": [ + "Use bracket notation to find the 3rd character in the lastName variable.", + "Bracket notation is a way to get a character at a specific index within a string.", + "Computers don't start counting at 1 like humans do. They start at 0.", + "For example, the character at index 0 in the word \"Julie\" is \"J\". So if var firstName = \"Julie\", you can get the value of the first letter of the string by using firstName[0].", + "Try looking at the secondLetterOfFirstName variable declaration if you get stuck." + ], + "tests": [ + "expect(thirdLetterOfLastName).to.equal('e');" + ], + "challengeSeed": [ + "var firstName = \"Madeline\";", + "", + "var secondLetterOfFirstName = firstName[1];", + "", + "var lastName = \"Chen\";", + "", + "var thirdLetterOfLastName = lastName;", + "", + "", + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "function returnValue(thirdLetterOfLastName) {", + " return thirdLetterOfLastName;", + "}", + "returnValue(thirdLetterOfLastName);" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c451eddfaeb5bdef", + "name": "Use Bracket Notation to Find the Last Character in a String", + "difficulty": "9.9812", + "description": [ + "Use bracket notation to find the last character in the lastName variable.", + "For example, the character at index 0 in the word \"Julie\" is \"J\". So if var firstName = \"Julie\", you can get the value of the first letter of the string by using firstName[0].", + "In order to get the last letter of a string, you can subtract one from the string's length.", + "For example, if var firstName = \"Julie\", you can get the value of the last letter of the string by using firstName[firstName.length - 1].", + "Try looking at the lastLetterOfLastName variable declaration if you get stuck." + ], + "tests": [ + "expect(lastLetterOfLastName).to.equal('n');" + ], + "challengeSeed": [ + "var firstName = \"Madeline\";", + "", + "var lastLetterOfFirstName = firstName[firstName.length - 1];", + "", + "var lastName = \"Chen\";", + "", + "var lastLetterOfLastName = lastName;", + "", + "", + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "function returnValue(lastLetterOfLastName) {", + " return lastLetterOfLastName;", + "}", + "returnValue(lastLetterOfLastName);" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c452eddfaeb5bdef", + "name": "Use Bracket Notation to Find the Nth to Last Character in a String", + "difficulty": "9.9813", + "description": [ + "Use bracket notation to find the second-to-last character in the lastName variable.", + "For example, the character at index 0 in the word \"Julie\" is \"J\". So if var firstName = \"Julie\", you can get the value of the first letter of the string by using firstName[0].", + "In order to get the last letter of a string, you can subtract one from the string's length.", + "For example, if var firstName = \"Julie\", you can get the value of the third-to-last letter of the string by using firstName[firstName.length - 3].", + "Try looking at the lastLetterOfLastName variable declaration if you get stuck." + ], + "tests": [ + "expect(secondToLastLetterOfLastName).to.equal('e');" + ], + "challengeSeed": [ + "var firstName = \"Madeline\";", + "", + "var thirdToLastLetterOfFirstName = firstName[firstName.length - 2];", + "", + "var lastName = \"Chen\";", + "", + "var secondToLastLetterOfLastName = lastName;", + "", + "", + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "function returnValue(secondToLastLetterOfLastName) {", + " return secondToLastLetterOfLastName;", + "}", + "returnValue(secondToLastLetterOfLastName);" + ], + "challengeType": 1 + } + ] +} From db324186da9466aac2f37e1fe5df78acb6b812ab Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Sun, 5 Jul 2015 17:15:54 -0700 Subject: [PATCH 03/13] update showjs view --- server/views/coursewares/showJS.jade | 141 +++++++++++++++------------ 1 file changed, 79 insertions(+), 62 deletions(-) diff --git a/server/views/coursewares/showJS.jade b/server/views/coursewares/showJS.jade index 9583a8672b..d6272540b5 100644 --- a/server/views/coursewares/showJS.jade +++ b/server/views/coursewares/showJS.jade @@ -1,88 +1,105 @@ extends ../layout-wide block content - script(src='/js/lib/codemirror/lib/codemirror.js') - script(src='/js/lib/codemirror/addon/edit/closebrackets.js') - script(src='/js/lib/codemirror/addon/edit/matchbrackets.js') - script(src='/js/lib/codemirror/addon/lint/lint.js') - script(src='/js/lib/codemirror/addon/lint/javascript-lint.js') - script(src='/bower_components/jshint/dist/jshint.js') - script(src='/js/lib/chai/chai.js') + script(type='text/javascript', src='/js/lib/codemirror/lib/codemirror.js') + script(type='text/javascript', src='/js/lib/codemirror/addon/edit/closebrackets.js') + script(type='text/javascript', src='/js/lib/codemirror/addon/edit/matchbrackets.js') + script(type='text/javascript', src='/js/lib/codemirror/addon/lint/lint.js') + script(type='text/javascript', src='/js/lib/codemirror/addon/lint/javascript-lint.js') + script(type='text/javascript', src='/bower_components/jshint/dist/jshint.js') + script(type='text/javascript', src='/js/lib/chai/chai.js') link(rel='stylesheet', href='/js/lib/codemirror/lib/codemirror.css') link(rel='stylesheet', href='/js/lib/codemirror/addon/lint/lint.css') link(rel='stylesheet', href='/js/lib/codemirror/theme/monokai.css') link(rel="stylesheet", href="//fonts.googleapis.com/css?family=Ubuntu+Mono") - script(src='/js/lib/codemirror/mode/javascript/javascript.js') - script(src='/js/lib/jailed/jailed.js') - script(src='/js/lib/coursewares/sandbox.js') - .row - .col-xs-12.col-sm-12.col-md-4.bonfire-top + script(type='text/javascript', src='/js/lib/codemirror/mode/javascript/javascript.js') + script(type='text/javascript', src='/js/lib/jailed/jailed.js') + script(type='text/javascript', src='/js/lib/coursewares/sandbox.js') + .row(ng-controller="pairedWithController") + .col-xs-12.col-sm-12.col-md-4.col-lg-3 .scroll-locker - #testCreatePanel - h1.text-center= name - .well - .row + #testCreatePanel.well + h3.text-center.negative-10= name + .row + .col-xs-12 + .bonfire-instructions + for sentence in details + p.wrappable.negative-10!= sentence + .negative-bottom-margin-30 + #MDN-links + p.negative-10 Here are some helpful links: + for link, index in MDNlinks + .negative-10 + ul: li: a(href="" + link, target="_blank") !{MDNkeys[index]} + if (user) + form.form-horizontal(novalidate='novalidate', name='completedWithForm') + .form-group.text-center.negative-10 .col-xs-12 - .bonfire-instructions - p.wrappable= brief - #brief-instructions - #more-info.btn.btn-primary.btn-block.btn-primary-ghost - span.ion-arrow-down-b - | More information - #long-instructions.row.hide - .col-xs-12 - for sentence in details - p.wrappable!= sentence - #less-info.btn.btn-primary.btn-block.btn-primary-ghost - span.ion-arrow-up-b - | Less information - #submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter) - .button-spacer - .btn-group.input-group.btn-group-justified - label.btn.btn-success#trigger-help-modal - i.fa.fa-medkit - |   Help - label.btn.btn-success#trigger-pair-modal - i.fa.fa-user-plus - |   Pair - label.btn.btn-success#trigger-issue-modal - i.fa.fa-bug - |   Bug - .spacer - form.code - .form-group.codeMirrorView - textarea#codeOutput(style='display: none;') - br - #testSuite - br - script(type="text/javascript"). - var tests = !{JSON.stringify(tests)}; - var challengeSeed = !{JSON.stringify(challengeSeed)}; - var challenge_Id = !{JSON.stringify(challengeId)}; - var challenge_Name = !{JSON.stringify(name)}; - var challengeType = !{JSON.stringify(challengeType)}; - var started = Math.floor(Date.now()); - + // extra field to distract password tools like lastpass from injecting css into our username field + label.negative-10.btn.btn-primary.btn-block#submitButton + i.fa.fa-play + |   Run code (ctrl + enter) + .button-spacer + .btn-group.input-group.btn-group-justified + label.btn.btn-success#trigger-reset-modal + i.fa.fa-refresh + |   Reset + label.btn.btn-success#trigger-help-modal + i.fa.fa-medkit + |   Help + label.btn.btn-success#trigger-issue-modal + i.fa.fa-bug + |   Bug + .button-spacer + form.code + .form-group.codeMirrorView + textarea#codeOutput(style='display: none;') + br + #testSuite.negative-10 + br + script(type="text/javascript"). + var tests = !{JSON.stringify(tests)}; + var challengeSeed = !{JSON.stringify(challengeSeed)}; + var challenge_Id = !{JSON.stringify(challengeId)}; + var challenge_Name = !{JSON.stringify(name)}; + var started = Math.floor(Date.now()); + var challengeType = !{JSON.stringify(challengeType)}; + var _ = R; + var dashed = !{JSON.stringify(dashedName)}; .col-xs-12.col-sm-12.col-md-8 #mainEditorPanel form.code .form-group.codeMirrorView textarea#codeEditor(autofocus=true, style='display: none;') - script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.5.js') + script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.6.js') #complete-courseware-dialog.modal(tabindex='-1') .modal-dialog.animated.zoomIn.fast-animation .modal-content .modal-header.challenge-list-header= compliment - a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × - .modal-body(ng-controller="pairedWithController") + a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + .modal-body .text-center .animated.zoomInDown.delay-half span.completion-icon.ion-checkmark-circled.text-primary if (user) - a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next challenge (ctrl + enter) - if (points && points > 2) - a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{dashedName}&hashtags=LearnToCode, JavaScript" target="_blank") + a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf) Go to my next challenge (ctrl + enter) + if (user.progressTimestamps.length > 2) + a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank", href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{dashedName}&hashtags=LearnToCode, JavaScript") i.fa.fa-twitter   = phrase else a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress + #reset-modal.modal(tabindex='-1') + .modal-dialog.animated.fadeInUp.fast-animation + .modal-content + .modal-header.challenge-list-header Clear your code? + a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + .modal-body + h3 This will restore your code editor to its original state. + a.btn.btn-lg.btn-info.btn-block#reset-button(href='#', data-dismiss='modal', aria-hidden='true') Clear my code + a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel include ../partials/challenge-modals + script. + var MDNlinks = !{JSON.stringify(MDNlinks)}; + if (!MDNlinks.length) { + $('#MDN-links').addClass('collapse'); + } From 27df13236736a99feed7c43f9547d03dd8ef98f5 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Thu, 9 Jul 2015 00:26:16 +0100 Subject: [PATCH 04/13] Update 2 of the new js curriculum! 7 more challenges added! --- seed/challenges/basic-javascript.json | 683 +++++++++++++++++++++----- 1 file changed, 553 insertions(+), 130 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 9a533cfe1c..836e2d5285 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -2,18 +2,47 @@ "name": "Basic JavaScript", "order": 0.006, "challenges": [ + { + "_id":"bd7123c9c441eddfaeb4bdef", + "name":"Welcome To Comments", + "dashedName":"waypoint-welcome-to-comments", + "difficulty":"9.98", + "description":[ + "", + "A comment is a very useful line of code that is not actually ran by the machine executing it. With this property comments are the perfect way of creating notes to yourself or anyone else who reads your code describing what the code does", + "It's an extremely important part in writing good, efficient and maintainable code and a requirement by most employers", + "Let's take a look at the two ways in which we can write a comment in JavaScript", + " //This is a comment ", + "These comment out the entire line that they are on", + " /*This also is a comment*/ ", + "These comment out everything in between /* and */ ", + "Try creating one of each now." + ], + "tests":[ + "assert(editor.getValue().match(/(\\/\\*)...../g), 'Make sure you have at least one \/\\* \\*\/ style comment that has at least three letters in it');", + "assert(editor.getValue().match(/(\\*\\/)/g), 'Make sure that you close the coment with a \\*\/');", + "assert(editor.getValue().match(/(\\/\\/)...../g), 'Make sure that there is at least one \\/\\/ style comment with at least three letters in it');" + ], + "challengeSeed":[ + + ], + "challengeType": 1 + }, { "_id": "bd7123c9c441eddfaeb5bdef", - "name": "Meet Booleans", - "dashedNname": "waypoint-meet-booleans", - "difficulty": "9.98", + "name": "Unconditionally Loving Booleans", + "dashedName": "waypoint-unconditionally-loving-booleans", + "difficulty": "9.98001", "description": [ "Return true", - "Some additional directions" + "A boolean is a type of variable that represents either true or false (Named after the British mathematician George Boole).", + "Booleans are often the result of a function or a comparative operation, for example 1==1 is true whereas 1==2 is false.", + "They are most commonly found inside if statements which we shall cover later", + "For now Let's modify our welcomeToBooleans function so that it will return true instead of false when the run button is clicked" ], "tests": [ - "expect(welcomeToBooleans()).to.be.a(\"boolean\");", - "expect(welcomeToBooleans()).to.be.true;" + "assert(typeof(welcomeToBooleans())=='boolean', 'The value returned by welcomeToBooleans() should be a boolean value. (true of false)');", + "assert(welcomeToBooleans() == true, 'The value returned by welcomeToBooleans() should be true');" ], "challengeSeed": [ "function welcomeToBooleans() {", @@ -25,153 +54,146 @@ ], "challengeType": 1 }, - { - "_id": "bd7123c9c442eddfaeb5bdef", - "name": "Define Your Name", - "difficulty": "9.9801", - "description": [ - "Set the value of myName to your name by typing your name in quotes.", - "Currently myName is empty. Type in your name and hit the submit button.", - "Look at the ourName example if you get stuck." - ], - "tests": [ - "expect(myName).to.be.a(\"string\");", - "expect(myName).length.not.to.be(0);" - ], - "challengeSeed": [ - "// ourName = \"Free Code Camp\";", - "myName = \"\";" - ], - "challengeType": 1 - }, { "_id": "bd7123c9c443eddfaeb5bdef", "name": "Start Using Variables", - "difficulty": "9.9802", + "dashedName": "waypoint-start-using-variables", + "difficulty": "9.9801", "description": [ + "", "Now, use the var keyword to create a variable called myName. Set its value to your name.", "Variables are used to store values.", + "The name variable comes from the fact that it's value, varies!", + "Now Let's create our first variable called myName and because it's a name let's make it a string!", "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in camel case. An example of camel case is: camelCase.", "Look at the ourName example if you get stuck." ], "tests": [ - "expect(myName).to.be.a(\"string\");", - "expect(myName).length.not.to.be(0);" + "assert(typeof(myName) == 'string', \"You're new variable should be a string\");", + "assert(myName.length > 0, \"You're string should have something in it!\");" ], "challengeSeed": [ "// var ourName = \"Free Code Camp\";", - "" + "", + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "(function(v){return(v);})(ourName);" + ], + "challengeType": 1 + }, + { + "_id": "bd7123c9c442eddfaeb5bdef", + "name": "Define Your Name", + "dashedName": "waypoint-define-your-name", + "difficulty": "9.9802", + "description": [ + "", + "In this challenge we are going to take a look at strings.", + "Strings are a data type for words and sentences", + "Now we are going to set the value of myName to your name by typing your name in quotes.", + "Currently myName is empty. Type in your name and hit the submit button.", + "Look at the ourName example if you get stuck." + ], + "tests": [ + "assert(typeof(myName) == 'string', 'The variable myName should be a string');", + "assert(myName.length > 0, 'Give the string myName a value');" + ], + "challengeSeed": [ + "// ourName = \"Free Code Camp\";", + "myName = \"\";", + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "(function(v){return(v);})(myName);" ], "challengeType": 1 }, { "_id": "bd7123c9c444eddfaeb5bdef", "name": "Define Your First and Last Name", - "difficulty": "9.9803", + "dashedName": "waypoint-define-your-first-and-last-name", + "difficulty": "9.9804", "description": [ - "Now, use the var keyword to create a variable called myFirstName and set its value to your first name. Then set a variable called myLastName to your last name.", - "Variables are used to store values.", - "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", - "Look at the ourFirstName and ourLastName examples if you get stuck." + "", + "Programs will almost always have several different variables that are used to keep track of several different pieces of data", + "We are now going to go and create two new variables myFirstName and myLastName that are strings", + "You can assign these variables to be equal to your first and last names respectively." ], "tests": [ - "expect(myFirstName).to.be.a(\"string\");", - "expect(myFirstName).length.not.to.be(0);", - "expect(myLastName).to.be.a(\"string\");", - "expect(myLastName).length.not.to.be(0);" + "assert(typeof(myFirstName) == 'string', 'myFirstName should be set to a string');", + "assert(typeof(myLastName) == 'string', 'myLastName should be set to a string');", + "assert(myFirstName.length > 0, 'myFirstName Should not be empty');", + "assert(myLastName.length > 0, 'myLastName should not be empty');", + "assert(typeof(myName) == 'string', 'The variable myName should be a string');", + "assert(myName.length > 0, 'Give the string myName a value');" ], "challengeSeed": [ + "// ourName = \"Free Code Camp\";", "// var ourFirstName = \"Free\";", "// var ourLastName = \"Code Camp\";", "", - "" + "var myName = \"\";", + "", + "", + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "(function(v){return(v);})(myName);" ], "challengeType": 1 }, { "_id": "bd7123c9c445eddfaeb5bdef", "name": "Combine Two Strings into One String", - "difficulty": "9.9804", + "dashedName": "waypoint-combine-two-variables-into-one-string", + "difficulty": "9.9805", "description": [ "Make a variable called myName by adding the string of your first name to the string of your last name.", "Strings can be combined in a process called concatenation.", - "Be sure to include a space at the end of your first string. Otherwise the two strings will not have a space between them.", + "We are now going to take the two variables myFirstName and myLastName and assign them values", + "Once we have given values to our two variables we can now concatenate them together with a space in between them", "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", "Look at the ourName example if you get stuck." ], "tests": [ - "expect(myName).to.be.a(\"string\");", - "expect(myName).length.not.to.be(0);", - "expect((/\\s+/).test(myName)).to.be.true;" - ], - "challengeSeed": [ - "// var ourName = \"Free \" + \"Code Camp\";", - "", - "" - ], - "challengeType": 1 - }, - { - "_id": "bd7123c9c446eddfaeb5bdef", - "name": "Combine Two Variables into One Variable", - "difficulty": "9.9805", - "description": [ - "Make the variables myFirstName, myLastName, and myFullName. Concatenate my myFirstName to myLastName to create myFullName.", - "Strings can be combined in a process called concatenation.", - "Be sure to include a space at the end of myFirstName. Otherwise myFullName will not contain a space between your first and last names.", - "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", - "Look at the ourFullName example if you get stuck." - ], - "tests": [ - "expect(myFirstName).to.be.a(\"string\");", - "expect(myLastName).to.be.a(\"string\");", - "expect(myFullName).to.be.a(\"string\");", - "expect(myFullName).length.not.to.be(0);", - "expect((/\\s+/).test(myFullName)).to.be.true;" - ], - "challengeSeed": [ - "// var ourFirstName = \"Free \";", - "// var ourLastName = \"Code Camp\";", - "// var ourFullName = ourFirstName + ourLastName;", - "" - ], - "challengeType": 1 - }, - { - "_id": "bd7123c9c447eddfaeb5bdef", - "name": "Concatenate Both Variables and Strings into the Same Variable", - "difficulty": "9.9806", - "description": [ - "Make the variables myFirstName, myLastName, and myFullName. Concatenate my myFirstName to myLastName to create myFullName, but this time add the space as a separate string, not as part of myFirstName or myLastName.", - "Strings can be combined in a process called concatenation.", - "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", - "Look at the ourFullName example if you get stuck." - ], - "tests": [ - "expect(myFirstName).to.be.a(\"string\");", - "expect(myLastName).to.be.a(\"string\");", - "expect(myFullName).to.be.a(\"string\");", - "expect(myFullName).length.not.to.be(0);", - "expect((/\\s+/).test(myFullName)).to.be.true;" + "assert(typeof(myFirstName) == 'string', 'myFirstName should be set to a string');", + "assert(typeof(myLastName) == 'string', 'myLastName should be set to a string');", + "assert(myFirstName.length > 0, 'myFirstName Should not be empty');", + "assert(myLastName.length > 0, 'myLastName should not be empty');", + "assert(typeof(myName) == 'string', 'myName should be a string');", + "assert(myName.length > 0, \"You're string should have something in it!\");", + "assert((/\\s+/).test(myName) == true, 'myName shuold contain a space');" ], "challengeSeed": [ "// var ourFirstName = \"Free\";", "// var ourLastName = \"Code Camp\";", - "// var ourFullName = ourFirstName + \" \" + ourLastName;", - "" + "// var ourName = ourFirstName + \" \" + ourLastName;", + "", + "var myFirstName = \"\";", + "var myLastName = \"\";", + "var myName;", + "", + "", + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "(function(v){return(v);})(myName);" ], "challengeType": 1 }, { "_id": "bd7123c9c448eddfaeb5bdef", "name": "Check the Length Property of a String Variable", + "dashedName": "waypoint-check-the-length-property-of-a-string-variable", "difficulty": "9.9809", "description": [ + "", "Use the .length property to count the number of characters in the lastNameLength variable.", "For example, if we created a variable var firstName = \"Julie\", we could find out how long the string \"Julie\" is by using the firstName.length property." ], "tests": [ - "expect(lastNameLength).to.equal(4);" + "assert(lastNameLength == 4, 'lastNameLength should have a length of 4');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -187,16 +209,14 @@ "// You can ignore this.", "// We use this to show you the value of your variable in your output box.", "// We'll learn about functions soon.", - "function returnValue(lastNameLength) {", - " return lastNameLength;", - "}", - "returnValue(lastNameLength);" + "(function(v){return(v);})(lastNameLength);" ], "challengeType": 1 }, { "_id": "bd7123c9c549eddfaeb5bdef", "name": "Use Bracket Notation to Find the First Character in a String", + "dashedName": "waypoint-use-bracket-notation-to-find-the-first-character-in-a-string", "difficulty": "9.9810", "description": [ "Use bracket notation to find the first character in a the firstLetterOfLastName variable.", @@ -206,7 +226,7 @@ "Try looking at the firstLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "expect(firstLetterOfLastName).to.equal('C');" + "assert(firstLetterOfLastName == 'C', 'The first letter of firstLetterOfLastName should be a C');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -221,26 +241,23 @@ "// You can ignore this.", "// We use this to show you the value of your variable in your output box.", "// We'll learn about functions soon.", - "function returnValue(firstLetterOfLastName) {", - " return firstLetterOfLastName;", - "}", - "returnValue(firstLetterOfLastName);" + "(function(v){return(v);})(firstLetterOfLastName);" ], "challengeType": 1 }, { "_id": "bd7123c9c450eddfaeb5bdef", "name": "Use Bracket Notation to Find the Nth Character in a String", + "dashedName": "waypoint-use-bracket-notation-to-find-the-nth-character-in-a-string", "difficulty": "9.9811", "description": [ - "Use bracket notation to find the 3rd character in the lastName variable.", - "Bracket notation is a way to get a character at a specific index within a string.", - "Computers don't start counting at 1 like humans do. They start at 0.", - "For example, the character at index 0 in the word \"Julie\" is \"J\". So if var firstName = \"Julie\", you can get the value of the first letter of the string by using firstName[0].", + "Just like the last lesson where we used Bracket Notation to access the first letter we can use the same method to get the letters ar other positions", + "Don't forget that computers start counting at 0 so the first letter is actually the zeroth one", + "Let's now try to set thirdLetterOfLastName to equal the third letter of the lastName variable", "Try looking at the secondLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "expect(thirdLetterOfLastName).to.equal('e');" + "assert(thirdLetterOfLastName == 'e', thirdLetterOfLastName);" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -255,16 +272,14 @@ "// You can ignore this.", "// We use this to show you the value of your variable in your output box.", "// We'll learn about functions soon.", - "function returnValue(thirdLetterOfLastName) {", - " return thirdLetterOfLastName;", - "}", - "returnValue(thirdLetterOfLastName);" + "(function(v){return(v);})(thirdLetterOfLastName);" ], "challengeType": 1 }, { "_id": "bd7123c9c451eddfaeb5bdef", "name": "Use Bracket Notation to Find the Last Character in a String", + "dashedName": "waypoint-use-bracket-notation-to-find-the-last-character-in-a-string", "difficulty": "9.9812", "description": [ "Use bracket notation to find the last character in the lastName variable.", @@ -274,7 +289,7 @@ "Try looking at the lastLetterOfLastName variable declaration if you get stuck." ], "tests": [ - "expect(lastLetterOfLastName).to.equal('n');" + "assert(lastLetterOfLastName == 'n', 'lastLetterOfLastName should be n');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -286,19 +301,14 @@ "var lastLetterOfLastName = lastName;", "", "", - "// You can ignore this.", - "// We use this to show you the value of your variable in your output box.", - "// We'll learn about functions soon.", - "function returnValue(lastLetterOfLastName) {", - " return lastLetterOfLastName;", - "}", - "returnValue(lastLetterOfLastName);" + "(function(v){return(v);})(lastLetterOfLastName);" ], "challengeType": 1 }, { "_id": "bd7123c9c452eddfaeb5bdef", "name": "Use Bracket Notation to Find the Nth to Last Character in a String", + "dashedName": "waypoint-use-bracket-notation-to-find-the-nth-to-last-character-in-a-string", "difficulty": "9.9813", "description": [ "Use bracket notation to find the second-to-last character in the lastName variable.", @@ -308,7 +318,7 @@ "Try looking at the lastLetterOfLastName variable declaration if you get stuck." ], "tests": [ - "expect(secondToLastLetterOfLastName).to.equal('e');" + "assert(secondToLastLetterOfLastName == 'e', 'secondToLastLetterOfLastName should be e');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -320,13 +330,426 @@ "var secondToLastLetterOfLastName = lastName;", "", "", - "// You can ignore this.", - "// We use this to show you the value of your variable in your output box.", - "// We'll learn about functions soon.", - "function returnValue(secondToLastLetterOfLastName) {", - " return secondToLastLetterOfLastName;", + "(function(v){return(v);})(secondToLastLetterOfLastName);" + ], + "challengeType": 1 + }, + { + "_id": "bd7993c9c69feddfaeb6bdef", + "name": "Magical Maths", + "dashedName": "waypoint-magical-maths", + "difficulty": "9.9814", + "description": [ + "", + "In JavaScript whole numbers (called integers) can be really easily to preform mathematical functions", + "Let's try a few of the most commonly used ones now", + "We use + for addition", + "We use - for subtraction", + "We use * for multiplication", + "We use / for division", + "Replace the _ with correct number to achieve the result in the comment." + ], + "tests": [ + "assert(add==20, 'The result of the sum in add should be 20');", + "assert(subtract==12, 'The result of the sum in add should be 12');", + "assert(multiply==80, 'The result of the sum in add should be 80');", + "assert(divide==2, 'The result of the sum in add should be 2');" + ], + "challengeSeed": [ + "var add = 10 + _;//equals 20", + "var subtract = 45 - _;//equals 12", + "var multiply = 8 * _;//equals 80", + "var divide = 66 / _;//equals 2", + "", + "", + "", + "(function(w,x,y,z){return('add='+w+', subtract='+x+', multiply='+y+', divide='+z);})(add,subtract,multiply,divide);" + ], + "challengeType": 1 + }, + { + "_id": "bd7993c9c69feddfaeb7bdef", + "name": "Working With Decimals", + "dashedName": "waypoint-working-with-decimals", + "difficulty": "9.9815", + "description": [ + "", + "in JavaScript we can can work with decimal numbers", + "These decal numbers are known as floats.", + "Let's take a look at working with floats now" + ], + "tests": [ + "assert(add == 13.5, 'The result of add should be 13.5');", + "assert(subtract == 7.25, 'The result of subtract should be 7.25');", + "assert(multiply == 15, 'The result of multiply should be 3.75');", + "assert(divide == 2.25, 'The result of divide should be 2.25');" + ], + "challengeSeed": [ + "var add = 9 + _;//equals 13.5", + "var subtract = 12 - _;//equals 7.25", + "var multiply = 3.75 * _;//equals 15", + "var divide = 9 / _;//equals 2.25", + "", + "", + "", + "(function(w,x,y,z){return('add='+w+', subtract='+x+', multiply='+y+', divide='+z);})(add,subtract,multiply,divide);" + ], + "challengeType": 1 + }, + { + "_id": "bd7993c9c69feddfaeb8bdef", + "name": "An Array Of new Information", + "dashedName": "waypoint-an-array-of-new-information", + "difficulty": "9.9816", + "description": [ + "", + "In JavaScript we can store lists or collections of data in what are called arrays", + "Arrays are distinguished by the [ and ] around the data. Each piece of data is separated be a , ", + "Now let's create a new array called myArray with a string , a number and a array with a , separating each one", + "Refer to the example if you get stuck", + "" + ], + "tests": [ + "assert(typeof(myArray) == 'object', 'myArray should be an array');", + "assert(myArray[0] !== undefined && typeof(myArray[0]) == 'string', 'The fist item in myArray should be a string');", + "assert(myArray[1] !== undefined && typeof(myArray[1]) == 'number', 'The second item in myArray should be a number');", + "assert(myArray[2] !== undefined && typeof(myArray[2]) == 'object', 'The third item in myArray should be an array');" + ], + "challengeSeed": [ + "//var array = ['John', 23, [2, 'cat']];", + "", + "var myArray = [];", + "", + "", + "(function(z){return(z);})(myArray);" + ], + "challengeType": 1 + }, + { + "_id": "bg9994c9c69feddfaeb9bdef", + "name": "Manipulating Arrays With pop()", + "dashedName": "waypoint-manipulating-arrays-with-pop", + "difficulty": "9.9817", + "description": [ + "", + "When and array has been defined we still have the ability to make changes to it afterwards", + "One common way in which we can manipulate the data in an array is through .pop() ", + " .pop() is used to \"pop\" a value from the end of an array. We can retrieve this value by preforming the pop in a variable declaration.", + "any type of variable can be \"popped\" from and array", + "Let's try .pop() now" + ], + "tests": [ + "assert((function(d){if(d[0] == 'John' && d[1] == 23 && d[2] == undefined){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23])');", + "assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return(true);}else{return(false);}})(removed), 'myArray should only have the first two values left([\"cat\"], 2)');" + ], + "challengeSeed": [ + "//var numbers = [1,2,3];", + "//console.log(numbers); //Gives [1,2,3]", + "//var removed = numbers.pop();", + "//console.log(numbers); //Gives [1,2]", + "//console.log(removed); //Gives 3", + "", + "var myArray = ['John', 23, ['cat', 2]];", + "var removed = _;//This should be ['cat', 2] and myArray should now be ['John', 23]", + "", + "", + "(function(y, z){return('myArray = ' + JSON.stringify(y) + ' & removed = ' + JSON.stringify(z));})(myArray, removed);" + ], + "challengeType": 1 + }, + { + "_id": "bg9995c9c69feddfaeb9bdef", + "name": "Manipulating Arrays With push()", + "dashedName": "waypoint-manipulating-arrays-with-push", + "difficulty": "9.9818", + "description": [ + "", + "Now that we've learn how to pop things from the end of the array, we need to learn how to push stuff back to the end", + "Let's take the code we had last time and push this value to the end: ['dog', 3] " + ], + "tests": [ + "assert((function(d){if(d[2] != undefined && d[0] == 'John' && d[1] == 23 && d[2][0] == 'dog' && d[2][1] == 3){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23, [\"dog\", 3]])');" + ], + "challengeSeed": [ + "var myArray = ['John', 23, ['cat', 2]];", + "var removed = myArray.pop();", + "//Add a ['dog', 3] to the end of myArray using push", + "", + "", + "(function(z){return('myArray = ' + JSON.stringify(z));})(myArray);" + ], + "challengeType": 1 + }, + { + "_id": "bg9996c9c69feddfaeb9bdef", + "name": "Manipulating Arrays With shift()", + "dashedName": "waypoint-manipulating-arrays-with-shift", + "difficulty": "9.9817", + "description": [ + "", + "Another common way in which we can manipulate the data in an array is through .shift() ", + " .shift() is used to \"shift\" a value from the start of an array. We can retrieve this value by preforming the shift in a variable declaration.", + "Let's try .shift() now" + ], + "tests": [ + "assert((function(d){if(d[0] == 23 && d[1][0] == 'dog' && d[1][1] == 3 && d[2] == undefined){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23])');", + "assert((function(d){if(d == 'John'){return(true);}else{return(false);}})(removed), 'Removed should contain \"John\"');" + ], + "challengeSeed": [ + "var myArray = ['John', 23, ['dog', 3]];", + "var removed = _;//This should be ['John'] and myArray should now be ['John', 23]", + "", + "", + "(function(y, z){return('myArray = ' + JSON.stringify(y) + ' & removed = ' + JSON.stringify(z));})(myArray, removed);" + ], + "challengeType": 1 + }, + { + "_id": "bg9997c9c69feddfaeb9bdef", + "name": "Manipulating Arrays With unshift()", + "dashedName": "waypoint-manipulating-arrays-with-unshift", + "difficulty": "9.9818", + "description": [ + "", + "Now that we've learned how to shift things from the start of the array, we need to learn how to unshift stuff back to the start", + "Let's take the code we had last time and unshift this value to the end: 'Paul' " + ], + "tests": [ + "assert((function(d){if(d[0].toLowerCase() == 'paul' && d[1] == 23 && d[2][0] != undefined && d[2][0] == 'dog' && d[2][1] != undefined && d[2][1] == 3){return(true);}else{return(false);}})(myArray), 'myArray should now have [\"Paul\", 23, [\"dog\", 3]])');" + ], + "challengeSeed": [ + "var myArray = ['John', 23, ['dog', 3]];", + "var removed = myArray.shift();//This should be 'John' and myArray should now be [23, ['dog', 3]]", + "//Add 'Paul' to the start of myArray", + "", + "", + "(function(y, z){return('myArray = ' + JSON.stringify(y));})(myArray);" + ], + "challengeType": 1 + }, + { + "_id":"bg9997c9c79feddfaeb9bdef", + "name":"Manipulating Arrays Indexes", + "dashedName":"waypoint-manipulating-arrays-indexes", + "difficulty":"9.9818", + "description":[ + "", + "With Arrays, we can access and modify the data inside them using indexes much like we did with strings. The major difference between using indexes with arrays versus using them in strings is that you cannot modify data in a string using and index.", + "In Arrays though we are freely allowed to change values in an array.", + "Let's have a go and accessing the last item in myArray and changing the middle value tp 25 ", + "Take a look at the commented out example above if you get stuck" + ], + "tests":[ + "assert((function(a){if(a[0] != undefined && a[0] == 'Paul' && a[1] != undefined && a[1] == 25 && a[2][0] != undefined && a[2][0] == 'dog' && a[2][1] != undefined && a[2][1] == 3){return(true);}else{return(false);}})(myArray), 'myArray should be [\"John\", \"David\",\"Paul\"]');", + "assert((function(l){if(l[0] != undefined && l[0] == 'dog' && l[1] != undefined && l[1] == 3){return(true);}else{return(false);}})(last), 'The last variable in myArray should be [\"dog\", 3]');" + ], + "challengeSeed":[ + "//var ourArray = ['Alpha', 'Beta', 'Gamma'];", + "//ourArray[0];//the first item in the array is 'Alpha'", + "//ouArray[1] = 'Omega';//The second item int the array is nom Omega instead of Beta", + "", + "var myArray = ['Paul', 23, ['dog', 3]];", + "var last = _;//Set this to be the last variable in the array using an index", + "", + "//Now set the second item in the Array to be 25 using an index'", + "", + "", + "", + "(function(y,z){return('myArray = ' + JSON.stringify(y) + ', last = ' + JSON.stringify(z));})(myArray, last);" + ], + "challengeType": 1 + }, + { + "_id":"bg9997c9c89feddfaeb9bdef", + "name":"Make it functional", + "dashedName":"waypoint-make-it-functional", + "difficulty":"9.9819", + "description":[ + "", + "In JavaScript we can divide up our code into separate and reusable parts called functions", + "here's and example of a function", + "", + "function funcitonName (one, two ,three){", + " /*Some Code*/", + "}", + "", + "our function can be called like this", + "functionName();", + "Let's try creating and calling a function now." + ], + "tests":[ + "assert(f==data);" + ], + "challengeSeed":[ + "//var ourData = 'function called!';", + "//function ourFunction(ourData) {/*ourData is being passed to this function as an argument*/", + "//return(data);", + "//}", + "", + "var data = 'Function Called!';", + "", + "//Create a function called myFunction that takes data as an argument and returns it like the example above", + "", + "", + "", + "", + "", + "//Don't modify this!", + "var f=myFunction(data);", + "(function(){var f=myFunction(data);return(f);})('');" + ], + "challengeType": 1 + }, + { + "_id":"bg9997c9c99feddfaeb9bdef", + "name":"Doing things inside functions", + "dashedName":"waypoint-doing-things-inside-functions", + "difficulty":"9.982", + "description":[ + "", + "A function that takes the value you give it and returns it isn't very useful! So now let's get our functions to do something!", + "Starting from where we were last time let's make our function revers whatever we give it by chaining .split('') , .reverse() and .join('') " + ], + "tests":[ + "assert(f==data.split('').reverse().join(''), 'myFunction should now return the reversed version of data (!dellaC noitcnuF)');" + ], + "challengeSeed":[ + "//You can reverse strings like this", + "//var notReversed = 'String';", + "//var reversed = notReversed.split('').reverse().join('');", + "", + "var data = 'Function Called!';", + "", + "function myFunction(data){", + " ", + " return(data);", "}", - "returnValue(secondToLastLetterOfLastName);" + "", + "", + "", + "//Don't modify this!", + "var f=myFunction(data);", + "(function(f){return(f);})(f);" + ], + "challengeType": 1 + }, + { + "_id":"bg9997c9c99feddfaeb9bdef", + "name":"Keeping In The Scope Of Things", + "dashedName":"waypoint-keeping-in-the-scope-of-things", + "difficulty":"9.9821", + "description":[ + "", + "All variables are contained in something called a scope .", + "A Scope defines where are variable can be accessed.", + "All variables created outside any functions exist in what is called the global scope ", + "All variables are container or are scope to inside that function.", + "", + "var variable = 'Global Scope'", + "function test(){", + " return(variable);", + "}", + "test();//Returns Global Scope", + "", + "function change(){", + " variable = 'test';", + " return(variable);", + "}", + "", + "change();//Returns test", + "variable //equals Global Scope", + "", + "", + "Let's give this a go!" + ], + "tests":[ + "assert(Global == access(Global), 'access should return your Global var');", + "assert(Global != localChange(Global), 'localChange should return your Global var');" + ], + "challengeSeed":[ + "//Create Your global variable with any value here", + "var Global = _;", + "", + "//Make access() return you global variable", + "function access(){", + " ", + "}", + "", + "access();", + "", + "//Pass you global variable into localChange and modify it within the function", + "function localChange(){", + " ", + "}", + "", + "//Don't forget to call localChange here and pass your global variable", + "", + "", + "(function(x,y,z){return('access returns: ' + y(x) + ' & localChange returns: ' + z(x));})(Global, access, localChange);" + ], + "challengeType": 1 + }, + { + "_id":"bg9998c9c99feddfaeb9bdef", + "name":"I Object!", + "dashedName":"waypoint-i-object", + "difficulty":"9.9822", + "description":[ + "", + "A very important data type in javascript is the Object ", + " Objects a similar to arrays except that instead of using indexes to access and modify their data, Objects have what are called properties ", + "Here's a sample Object", + "", + "var cat = {", + " \"name\": \"Whiskers\",", + " \"legs\": 4,", + " \"tails\": 1,", + " \"enemies\": [\"Water\", \"Dogs\"]", + "};", + "", + "Objects are useful for storing data in a structured way or in a way that represents a real world object like a cat.", + "Let's try to make a Object that represents a dog called myDog!" + + ], + "tests":[ + "assert((function(z){if(z.hasOwnProperty('name') && z.name != undefined && typeof(z.name) == 'string'){return(true);}else{return(false);}})(myDog), 'myDog should contain the property name and it should be a string');", + "assert((function(z){if(z.hasOwnProperty('legs') && z.legs != undefined && typeof(z.legs) == 'number'){return(true);}else{return(false);}})(myDog), 'myDog should contain the property legs and it should be a number');", + "assert((function(z){if(z.hasOwnProperty('tails') && z.tails != undefined && typeof(z.tails) == 'number'){return(true);}else{return(false);}})(myDog), 'myDog should contain the property tails and it should be a number');", + "assert((function(z){if(z.hasOwnProperty('friends') && z.friends != undefined && Array.isArray(z.friends)){return(true);}else{return(false);}})(myDog), 'myDog should contain the property friends and it should be an array');" + ], + "challengeSeed":[ + "//var ourDog = {", + " //\"name\": \"Camper\"", + " //\"legs\": 4", + " //\"tails\": 1", + " //\"friends\": ['everything!']", + "//};", + "", + "/* add the name(string), legs(number), tails(number) and friends(array) properties to myDog.", + "You can set them to whatever you want!*/", + "", + "var myDog = {", + " ", + "};", + "", + "(function(z){return(z);})(myDog);" + ], + "challengeType": 1 + }, + { + "_id":"bg9999c9c99feddfaeb9bdef", + "name":"Manipulating Objects", + "dashedName":"waypoint-manipulating-objects", + "difficulty":"9.9823", + "description":[ + "", + "" + ], + "tests":[ + "assert(1==2);" + ], + "challengeSeed":[ + "" ], "challengeType": 1 } From 46066e5be151fcb6d5831203f9a764d19f3a454f Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Fri, 10 Jul 2015 00:56:30 +0100 Subject: [PATCH 05/13] Third commit to the new curriculum --- seed/challenges/basic-javascript.json | 224 +++++++++++++++++++++++++- 1 file changed, 219 insertions(+), 5 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 836e2d5285..8a2cc64030 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -719,10 +719,10 @@ ], "challengeSeed":[ "//var ourDog = {", - " //\"name\": \"Camper\"", - " //\"legs\": 4", - " //\"tails\": 1", - " //\"friends\": ['everything!']", + "// \"name\": \"Camper\"", + "// \"legs\": 4", + "// \"tails\": 1", + "// \"friends\": ['everything!']", "//};", "", "/* add the name(string), legs(number), tails(number) and friends(array) properties to myDog.", @@ -743,12 +743,226 @@ "difficulty":"9.9823", "description":[ "", + "Now that we have an objects we need to know how to add and remove properties from it", + "We add properties to objects like this", + "myObject['myProperty'] = \"myValue\";", + "They can also be deleted like this", + "delete(myObject[\"myProperty\"]);", + "Let's add the property bark", "" ], "tests":[ - "assert(1==2);" + "assert(myDog.bark != undefined, 'The property tails should have been deleted');", + "assert(myDog.tails == undefined, 'The property tails should have been deleted');" ], "challengeSeed":[ + "//var ourDog = {", + "//\"name\": \"Camper\"", + "//\"legs\": 4", + "//\"tails\": 1", + "//\"friends\": [\"everything!\"]", + "//};", + "", + "//Re-create myDog", + "", + "var myDog = {", + " \"name\": _,", + " \"legs\": _,", + " \"tails\": _,", + " \"friends\": []", + "};", + "", + "//Let's add the property age to myDog", + "", + "", + "//Now delete the property tails", + "", + "", + "(function(z){return(z);})(myDog);" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb5bdef", + "name":"Looping with for", + "dashedName":"waypoint-looping-with-for", + "difficulty":"9.9824", + "description":[ + "", + "Loops are a critical part of any program! The next few challenges", + "first we will be taking a look at the for loop", + "", + "var ourArray = [];", + "for(var i = 0; i < 5; i++){", + " ourArray.push(i);", + "}", + "", + "ourArray now contains [0,1,2,3,4] ", + "Let's try getting a for loop to work by pushing values to an array" + ], + "tests":[ + "assert(editor.getValue().match(/for\\(/g), 'You should be using a for loop for this!');", + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" + ], + "challengeSeed":[ + "var myArray = [];", + "//Push the numbers 0-4 to myArray", + "", + "" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb1bdef", + "name":"Looping with while", + "dashedName":"waypoint-looping-with-while", + "difficulty":"9.9825", + "description":[ + "", + "Loops are a critical part of any program! The next few challenges", + "first we will be taking a look at the for loop", + "", + "var ourArray = [];", + "var i = 0;", + "while(i < 5){", + " ourArray.push(i);", + " i++;", + "}", + "", + "Let's try getting a for loop to work by pushing values to an array" + ], + "tests":[ + "assert(editor.getValue().match(/while\\(/g), 'You should be using a while loop for this!');", + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" + ], + "challengeSeed":[ + "var myArray = [];", + "//Push the numbers 0-4 to myArray", + "", + "" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb2bdef", + "name":"Looping with do while", + "dashedName":"waypoint-looping-with-do-while", + "difficulty":"9.9826", + "description":[ + "", + "Let's now take a look at the do - while loop", + "", + "var ourArray = [];", + "var i = 0;", + "do{", + " ourArray.push(i);", + " i++;", + "}while(i<5);", + "", + "A do - while has a very special difference when compared to the for and while loops. The do while loop is guaranteed to execute preform it's action once regardless of whether or not the condition inside the while is met!", + "Let's try getting a do - while loop to work by pushing values to an array" + ], + "tests":[ + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');", + "assert((function(){if(editor.getValue().match(/do/g) && editor.getValue(/while/g).match()){return(true);}else{return(false);}})(), 'You should be using a do while loop for this!');" + ], + "challengeSeed":[ + "var myArray = [];", + "//Push the numbers 0-4 to myArray", + "", + "" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb3bdef", + "name":"Looping with recursion", + "dashedName":"waypoint-looping-with-recursion", + "difficulty":"9.9827", + "description":[ + "", + "The next method of looping that we'll examine is called recursion", + "A recursive function (a function that uses recursion) is a function that calls itself until a predefined condition is met", + "", + "var ourArray = [];", + "var i = 0;", + "function loop(){", + " ourArray.push(i);", + " i++;", + " if(i < 5){", + " loop()", + " }", + "}", + "", + "ourArray now contains [0,1,2,3,4] ", + "Let's try getting recursion to work by pushing values to an array" + ], + "tests":[ + "assert((function(){if(!editor.getValue().match(/do/g) && !editor.getValue().match(/while/g) && !editor.getValue().match(/for/g)){return(true);}else{return(false);}})(), 'You should be using recursion for this!')", + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" + ], + "challengeSeed":[ + "var myArray = [];", + "//Push the numbers 0-4 to myArray", + "", + "" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb4bdef", + "name":"Looping with map", + "dashedName":"waypoint-looping-with-map", + "difficulty":"9.9828", + "description":[ + "", + "Loops are a critical part of any program! The next few challenges", + "first we will be taking a look at the for loop", + "", + "var ourArray = [];", + "for(var i = 0; i < 5; i++){", + " ourArray.push(i);", + "}", + "", + "ourArray now contains [0,1,2,3,4] ", + "Let's try getting a for loop to work by pushing values to an array" + ], + "tests":[ + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" + ], + "challengeSeed":[ + "var myArray = [];", + "//Push the numbers 0-4 to myArray", + "", + "" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb6bdef", + "name":"Looping with reduce", + "dashedName":"waypoint-looping-with-reduce", + "difficulty":"9.9829", + "description":[ + "", + "Loops are a critical part of any program! The next few challenges", + "first we will be taking a look at the for loop", + "", + "var ourArray = [];", + "for(var i = 0; i < 5; i++){", + " ourArray.push(i);", + "}", + "", + "ourArray now contains [0,1,2,3,4] ", + "Let's try getting a for loop to work by pushing values to an array" + ], + "tests":[ + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" + ], + "challengeSeed":[ + "var myArray = [];", + "//Push the numbers 0-4 to myArray", + "", "" ], "challengeType": 1 From a39c398b8ca742ca59ebb5a486c4b2f1e27310ce Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Fri, 10 Jul 2015 17:22:58 +0100 Subject: [PATCH 06/13] Update to 30! --- seed/challenges/basic-javascript.json | 58 --------------------------- 1 file changed, 58 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 8a2cc64030..9a50f07b5c 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -908,64 +908,6 @@ "" ], "challengeType": 1 - }, - { - "_id":"bh1111c1c11feddfaeb4bdef", - "name":"Looping with map", - "dashedName":"waypoint-looping-with-map", - "difficulty":"9.9828", - "description":[ - "", - "Loops are a critical part of any program! The next few challenges", - "first we will be taking a look at the for loop", - "", - "var ourArray = [];", - "for(var i = 0; i < 5; i++){", - " ourArray.push(i);", - "}", - "", - "ourArray now contains [0,1,2,3,4] ", - "Let's try getting a for loop to work by pushing values to an array" - ], - "tests":[ - "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" - ], - "challengeSeed":[ - "var myArray = [];", - "//Push the numbers 0-4 to myArray", - "", - "" - ], - "challengeType": 1 - }, - { - "_id":"bh1111c1c11feddfaeb6bdef", - "name":"Looping with reduce", - "dashedName":"waypoint-looping-with-reduce", - "difficulty":"9.9829", - "description":[ - "", - "Loops are a critical part of any program! The next few challenges", - "first we will be taking a look at the for loop", - "", - "var ourArray = [];", - "for(var i = 0; i < 5; i++){", - " ourArray.push(i);", - "}", - "", - "ourArray now contains [0,1,2,3,4] ", - "Let's try getting a for loop to work by pushing values to an array" - ], - "tests":[ - "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" - ], - "challengeSeed":[ - "var myArray = [];", - "//Push the numbers 0-4 to myArray", - "", - "" - ], - "challengeType": 1 } ] } From 8072a4b7f2344f5af8c68cedc9f8ec33388a6569 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Fri, 10 Jul 2015 10:12:53 -0700 Subject: [PATCH 07/13] fix modal closing a on showJS view --- server/views/coursewares/showJS.jade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/views/coursewares/showJS.jade b/server/views/coursewares/showJS.jade index d6272540b5..5c7d86f10d 100644 --- a/server/views/coursewares/showJS.jade +++ b/server/views/coursewares/showJS.jade @@ -75,7 +75,7 @@ block content .modal-dialog.animated.zoomIn.fast-animation .modal-content .modal-header.challenge-list-header= compliment - a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × .modal-body .text-center .animated.zoomInDown.delay-half From 7af3c1c67d32174c2b939de200b5a5c3d1f089e3 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Mon, 13 Jul 2015 21:55:36 +0100 Subject: [PATCH 08/13] Full JS Stuff There is a bit more RegEx and if else stuff. Other challenges can be added later but this is the base working set without @QuincyLarson 's fixes to the copy --- seed/challenges/basic-javascript.json | 811 +++++++++++++++++++++----- 1 file changed, 665 insertions(+), 146 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 9a533cfe1c..993ce01944 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -2,18 +2,47 @@ "name": "Basic JavaScript", "order": 0.006, "challenges": [ + { + "_id":"bd7123c9c441eddfaeb4bdef", + "name":"Welcome To Comments", + "dashedName":"waypoint-welcome-to-comments", + "difficulty":"9.98", + "description":[ + "", + "A comment is a very useful line of code that is not actually ran by the machine executing it. With this property comments are the perfect way of creating notes to yourself or anyone else who reads your code describing what the code does", + "It's an extremely important part in writing good, efficient and maintainable code and a requirement by most employers", + "Let's take a look at the two ways in which we can write a comment in JavaScript", + " //This is a comment ", + "These comment out the entire line that they are on", + " /*This also is a comment*/ ", + "These comment out everything in between /* and */ ", + "Try creating one of each now." + ], + "tests":[ + "assert(editor.getValue().match(/(\\/\\*)...../g), 'Make sure you have at least one \/\\* \\*\/ style comment that has at least five letters in it');", + "assert(editor.getValue().match(/(\\*\\/)/g), 'Make sure that you close the coment with a \\*\/');", + "assert(editor.getValue().match(/(\\/\\/)...../g), 'Make sure that there is at least one \\/\\/ style comment with at least five letters in it');" + ], + "challengeSeed":[ + + ], + "challengeType": 1 + }, { "_id": "bd7123c9c441eddfaeb5bdef", - "name": "Meet Booleans", - "dashedNname": "waypoint-meet-booleans", - "difficulty": "9.98", + "name": "Unconditionally Loving Booleans", + "dashedName": "waypoint-unconditionally-loving-booleans", + "difficulty": "9.98001", "description": [ "Return true", - "Some additional directions" + "A boolean is a type of variable that represents either true or false (Named after the British mathematician George Boole).", + "Booleans are often the result of a function or a comparative operation, for example 1==1 is true whereas 1==2 is false.", + "They are most commonly found inside if statements which we shall cover later", + "For now Let's modify our welcomeToBooleans function so that it will return true instead of false when the run button is clicked" ], "tests": [ - "expect(welcomeToBooleans()).to.be.a(\"boolean\");", - "expect(welcomeToBooleans()).to.be.true;" + "assert(typeof(welcomeToBooleans())=='boolean', 'The value returned by welcomeToBooleans() should be a boolean value. (true of false)');", + "assert(welcomeToBooleans() == true, 'The value returned by welcomeToBooleans() should be true');" ], "challengeSeed": [ "function welcomeToBooleans() {", @@ -25,153 +54,74 @@ ], "challengeType": 1 }, - { - "_id": "bd7123c9c442eddfaeb5bdef", - "name": "Define Your Name", - "difficulty": "9.9801", - "description": [ - "Set the value of myName to your name by typing your name in quotes.", - "Currently myName is empty. Type in your name and hit the submit button.", - "Look at the ourName example if you get stuck." - ], - "tests": [ - "expect(myName).to.be.a(\"string\");", - "expect(myName).length.not.to.be(0);" - ], - "challengeSeed": [ - "// ourName = \"Free Code Camp\";", - "myName = \"\";" - ], - "challengeType": 1 - }, { "_id": "bd7123c9c443eddfaeb5bdef", "name": "Start Using Variables", - "difficulty": "9.9802", + "dashedName": "waypoint-start-using-variables", + "difficulty": "9.9801", "description": [ + "", "Now, use the var keyword to create a variable called myName. Set its value to your name.", "Variables are used to store values.", + "The name variable comes from the fact that it's value, varies!", + "Now Let's create our first variable called myName and because it's a name let's make it a string!", "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in camel case. An example of camel case is: camelCase.", "Look at the ourName example if you get stuck." ], "tests": [ - "expect(myName).to.be.a(\"string\");", - "expect(myName).length.not.to.be(0);" + "assert((function(){/**/if(typeof(myName) !== 'undefined' && typeof(myName) == 'string' && myName.length > 0){return(true);}else{return(false);}/**/})(), 'myName should be a string that contains at least one character in it');" ], "challengeSeed": [ "// var ourName = \"Free Code Camp\";", - "" + "", + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "", + "if(typeof(myName) !== 'undefined'){(function(v){return(v);})(myName);}" ], "challengeType": 1 }, { "_id": "bd7123c9c444eddfaeb5bdef", "name": "Define Your First and Last Name", - "difficulty": "9.9803", + "dashedName": "waypoint-define-your-first-and-last-name", + "difficulty": "9.9802", "description": [ - "Now, use the var keyword to create a variable called myFirstName and set its value to your first name. Then set a variable called myLastName to your last name.", - "Variables are used to store values.", - "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", - "Look at the ourFirstName and ourLastName examples if you get stuck." + "", + "Programs will almost always have several different variables that are used to keep track of several different pieces of data", + "We are now going to go and create two new variables myFirstName and myLastName that are strings", + "You can assign these variables to be equal to your first and last names respectively." ], "tests": [ - "expect(myFirstName).to.be.a(\"string\");", - "expect(myFirstName).length.not.to.be(0);", - "expect(myLastName).to.be.a(\"string\");", - "expect(myLastName).length.not.to.be(0);" + "assert((function(){if(typeof(myFirstName) !== 'undefined' && typeof(myFirstName) == 'string' && myFirstName.length > 0){return(true);}else{return(false);}})(), 'myFirstName should be a string with a least one character in it');", + "assert((function(){if(typeof(myLastName) !== 'undefined' && typeof(myLastName) == 'string' && myLastName.length > 0){return(true);}else{return(false);}})(), 'myLastName should be a string with a least one character in it');" ], "challengeSeed": [ + "// ourName = \"Free Code Camp\";", "// var ourFirstName = \"Free\";", "// var ourLastName = \"Code Camp\";", "", - "" - ], - "challengeType": 1 - }, - { - "_id": "bd7123c9c445eddfaeb5bdef", - "name": "Combine Two Strings into One String", - "difficulty": "9.9804", - "description": [ - "Make a variable called myName by adding the string of your first name to the string of your last name.", - "Strings can be combined in a process called concatenation.", - "Be sure to include a space at the end of your first string. Otherwise the two strings will not have a space between them.", - "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", - "Look at the ourName example if you get stuck." - ], - "tests": [ - "expect(myName).to.be.a(\"string\");", - "expect(myName).length.not.to.be(0);", - "expect((/\\s+/).test(myName)).to.be.true;" - ], - "challengeSeed": [ - "// var ourName = \"Free \" + \"Code Camp\";", "", - "" - ], - "challengeType": 1 - }, - { - "_id": "bd7123c9c446eddfaeb5bdef", - "name": "Combine Two Variables into One Variable", - "difficulty": "9.9805", - "description": [ - "Make the variables myFirstName, myLastName, and myFullName. Concatenate my myFirstName to myLastName to create myFullName.", - "Strings can be combined in a process called concatenation.", - "Be sure to include a space at the end of myFirstName. Otherwise myFullName will not contain a space between your first and last names.", - "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", - "Look at the ourFullName example if you get stuck." - ], - "tests": [ - "expect(myFirstName).to.be.a(\"string\");", - "expect(myLastName).to.be.a(\"string\");", - "expect(myFullName).to.be.a(\"string\");", - "expect(myFullName).length.not.to.be(0);", - "expect((/\\s+/).test(myFullName)).to.be.true;" - ], - "challengeSeed": [ - "// var ourFirstName = \"Free \";", - "// var ourLastName = \"Code Camp\";", - "// var ourFullName = ourFirstName + ourLastName;", - "" - ], - "challengeType": 1 - }, - { - "_id": "bd7123c9c447eddfaeb5bdef", - "name": "Concatenate Both Variables and Strings into the Same Variable", - "difficulty": "9.9806", - "description": [ - "Make the variables myFirstName, myLastName, and myFullName. Concatenate my myFirstName to myLastName to create myFullName, but this time add the space as a separate string, not as part of myFirstName or myLastName.", - "Strings can be combined in a process called concatenation.", - "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", - "Look at the ourFullName example if you get stuck." - ], - "tests": [ - "expect(myFirstName).to.be.a(\"string\");", - "expect(myLastName).to.be.a(\"string\");", - "expect(myFullName).to.be.a(\"string\");", - "expect(myFullName).length.not.to.be(0);", - "expect((/\\s+/).test(myFullName)).to.be.true;" - ], - "challengeSeed": [ - "// var ourFirstName = \"Free\";", - "// var ourLastName = \"Code Camp\";", - "// var ourFullName = ourFirstName + \" \" + ourLastName;", - "" + "// You can ignore this.", + "// We use this to show you the value of your variable in your output box.", + "// We'll learn about functions soon.", + "if(typeof(myFirstName) !== 'undefined' && typeof(myLastName) !== 'undefined'){(function(y,z){return(y + ', ' + z);})(myFirstName, myLastName);}" ], "challengeType": 1 }, { "_id": "bd7123c9c448eddfaeb5bdef", "name": "Check the Length Property of a String Variable", + "dashedName": "waypoint-check-the-length-property-of-a-string-variable", "difficulty": "9.9809", "description": [ + "", "Use the .length property to count the number of characters in the lastNameLength variable.", "For example, if we created a variable var firstName = \"Julie\", we could find out how long the string \"Julie\" is by using the firstName.length property." ], "tests": [ - "expect(lastNameLength).to.equal(4);" + "(function(){if(typeof(lastNameLength) != 'undefined' && typeof(lastNameLength) == 'number' && lastNameLength == 4){return(true);}else}{return(false);}}, 'lastNameLength should be equal to four')()" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -187,16 +137,14 @@ "// You can ignore this.", "// We use this to show you the value of your variable in your output box.", "// We'll learn about functions soon.", - "function returnValue(lastNameLength) {", - " return lastNameLength;", - "}", - "returnValue(lastNameLength);" + "if(typeof(lastNameLength) != 'undefined')(function(v){return(v);})(lastNameLength);}" ], "challengeType": 1 }, { "_id": "bd7123c9c549eddfaeb5bdef", "name": "Use Bracket Notation to Find the First Character in a String", + "dashedName": "waypoint-use-bracket-notation-to-find-the-first-character-in-a-string", "difficulty": "9.9810", "description": [ "Use bracket notation to find the first character in a the firstLetterOfLastName variable.", @@ -206,7 +154,7 @@ "Try looking at the firstLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "expect(firstLetterOfLastName).to.equal('C');" + "assert((function(){if(typeof(firstLetterOfLastName) != 'undefined' && typeof(firstLetterOfLastName) == 'string' && firstLetterOfLastName == 'C'){return(true);}else{return(false);}})(), 'The first letter of firstLetterOfLastName should be a C');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -221,26 +169,23 @@ "// You can ignore this.", "// We use this to show you the value of your variable in your output box.", "// We'll learn about functions soon.", - "function returnValue(firstLetterOfLastName) {", - " return firstLetterOfLastName;", - "}", - "returnValue(firstLetterOfLastName);" + "(function(v){return(v);})(firstLetterOfLastName);" ], "challengeType": 1 }, { "_id": "bd7123c9c450eddfaeb5bdef", "name": "Use Bracket Notation to Find the Nth Character in a String", + "dashedName": "waypoint-use-bracket-notation-to-find-the-nth-character-in-a-string", "difficulty": "9.9811", "description": [ - "Use bracket notation to find the 3rd character in the lastName variable.", - "Bracket notation is a way to get a character at a specific index within a string.", - "Computers don't start counting at 1 like humans do. They start at 0.", - "For example, the character at index 0 in the word \"Julie\" is \"J\". So if var firstName = \"Julie\", you can get the value of the first letter of the string by using firstName[0].", + "Just like the last lesson where we used Bracket Notation to access the first letter we can use the same method to get the letters ar other positions", + "Don't forget that computers start counting at 0 so the first letter is actually the zeroth one", + "Let's now try to set thirdLetterOfLastName to equal the third letter of the lastName variable", "Try looking at the secondLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "expect(thirdLetterOfLastName).to.equal('e');" + "assert(thirdLetterOfLastName == 'e', 'The third last letter of lastName should be an e');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -255,16 +200,14 @@ "// You can ignore this.", "// We use this to show you the value of your variable in your output box.", "// We'll learn about functions soon.", - "function returnValue(thirdLetterOfLastName) {", - " return thirdLetterOfLastName;", - "}", - "returnValue(thirdLetterOfLastName);" + "(function(v){return(v);})(thirdLetterOfLastName);" ], "challengeType": 1 }, { "_id": "bd7123c9c451eddfaeb5bdef", "name": "Use Bracket Notation to Find the Last Character in a String", + "dashedName": "waypoint-use-bracket-notation-to-find-the-last-character-in-a-string", "difficulty": "9.9812", "description": [ "Use bracket notation to find the last character in the lastName variable.", @@ -274,7 +217,8 @@ "Try looking at the lastLetterOfLastName variable declaration if you get stuck." ], "tests": [ - "expect(lastLetterOfLastName).to.equal('n');" + "assert(lastLetterOfLastName == 'n', 'lastLetterOfLastName should be n');", + "assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the last letter');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -286,19 +230,14 @@ "var lastLetterOfLastName = lastName;", "", "", - "// You can ignore this.", - "// We use this to show you the value of your variable in your output box.", - "// We'll learn about functions soon.", - "function returnValue(lastLetterOfLastName) {", - " return lastLetterOfLastName;", - "}", - "returnValue(lastLetterOfLastName);" + "(function(v){return(v);})(lastLetterOfLastName);" ], "challengeType": 1 }, { "_id": "bd7123c9c452eddfaeb5bdef", "name": "Use Bracket Notation to Find the Nth to Last Character in a String", + "dashedName": "waypoint-use-bracket-notation-to-find-the-nth-to-last-character-in-a-string", "difficulty": "9.9813", "description": [ "Use bracket notation to find the second-to-last character in the lastName variable.", @@ -308,7 +247,8 @@ "Try looking at the lastLetterOfLastName variable declaration if you get stuck." ], "tests": [ - "expect(secondToLastLetterOfLastName).to.equal('e');" + "assert(secondToLastLetterOfLastName == 'e', 'secondToLastLetterOfLastName should be e');", + "assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the third last letter');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -320,13 +260,592 @@ "var secondToLastLetterOfLastName = lastName;", "", "", - "// You can ignore this.", - "// We use this to show you the value of your variable in your output box.", - "// We'll learn about functions soon.", - "function returnValue(secondToLastLetterOfLastName) {", - " return secondToLastLetterOfLastName;", + "(function(v){return(v);})(secondToLastLetterOfLastName);" + ], + "challengeType": 1 + }, + { + "_id": "bh1111c1c11feddfaeb3bdef", + "name": "Magical Maths Addition", + "dashedName": "waypoint-magical-maths-addition", + "difficulty": "9.98141", + "description": [ + "", + "In JavaScript whole numbers (called integers) can be really easily to preform mathematical functions", + "Let's try a few of the most commonly used ones now", + "We use + for addition", + "Replace the 0 with correct number to achieve the result in the comment." + ], + "tests": [ + "assert((function(){if(add == 20 && editor.getValue().match(/\\+/g)){return(true);}else{return(false);}})(), 'Add should be the result of a sum and be equal to 20');" + ], + "challengeSeed": [ + "var add = 10 + 0;//equals 20", + "", + "", + "", + "(function(z){return('add='+z);})(add);" + ], + "challengeType": 1 + }, + { + "_id": "bh1111c1c11feddfaeb4bdef", + "name": "Magical Maths Subtraction", + "dashedName": "waypoint-magical-maths-subtraction", + "difficulty": "9.98142", + "description": [ + "", + "In JavaScript whole numbers (called integers) can be really easily to preform mathematical functions", + "Let's try a few of the most commonly used ones now", + "We use - for subtraction", + "Replace the 0 with correct number to achieve the result in the comment." + ], + "tests": [ + "assert((function(){if(subtract == 12 && editor.getValue().match(/\\-/g)){return(true);}else{return(false);}})(), 'Subtract should be the result of a sum and be equal to 12');" + ], + "challengeSeed": [ + "var subtract = 45 - 0;//equals 12", + "", + "", + "", + "(function(z){return('subtract='+z);})(subtract);" + ], + "challengeType": 1 + }, + { + "_id": "bh1111c1c11feddfaeb5bdef", + "name": "Magical Maths Multiplication", + "dashedName": "waypoint-magical-maths-multiplication", + "difficulty": "9.98143", + "description": [ + "", + "In JavaScript whole numbers (called integers) can be really easily to preform mathematical functions", + "Let's try a few of the most commonly used ones now", + "We use * for multiplication", + "Replace the 0 with correct number to achieve the result in the comment." + ], + "tests": [ + "assert((function(){if(multiply == 80 && editor.getValue().match(/\\*/g)){return(true);}else{return(false);}})(), 'Multiply should be the result of a sum and be equal to 80');" + ], + "challengeSeed": [ + "var multiply = 8 * 0;//equals 80", + "", + "", + "", + "(function(z){return('multiply='+z);})(multiply);" + ], + "challengeType": 1 + }, + { + "_id": "bh1111c1c11feddfaeb6bdef", + "name": "Magical Maths Division", + "dashedName": "waypoint-magical-maths-division", + "difficulty": "9.9814", + "description": [ + "", + "In JavaScript whole numbers (called integers) can be really easily to preform mathematical functions", + "Let's try a few of the most commonly used ones now", + "We use / for division", + "Replace the 0 with correct number to achieve the result in the comment." + ], + "tests": [ + "assert((function(){if(divide == 2 && editor.getValue().match(/\\//g)){return(true);}else{return(false);}})(), 'Divide should be the result of a sum and be equal to 2');" + ], + "challengeSeed": [ + "var divide = 66 / 0;//equals 2", + "", + "", + "", + "(function(z){return('divide='+z);})(divide);" + ], + "challengeType": 1 + }, + { + "_id": "bh1111c1c11feddfaeb4bdef", + "name": "Creating Decimals", + "dashedName": "waypoint-creating-decimals", + "difficulty": "9.9815", + "description": [ + "", + "in JavaScript we can can work with decimal numbers", + "These decal numbers are known as floats.", + "Let's create a float now called myFloat and give it a value" + ], + "tests": [ + "assert((function(){if(typeof(myFloat) != 'undefined' && typeof(myFloat) == 'number' && editor.getValue().match(/\\./g).length >=2){return(true);}else{return(false);}})(), 'myFloat should be a decimal point number');" + ], + "challengeSeed": [ + "//var ourFloat = 5.7", + "//Create a number with a decimal point here called myFloat", + "", + "", + "", + "", + "if(typeof(myFloat) != 'undefined'){(function(z){return(z);})(myFloat);}" + ], + "challengeType": 1 + }, + { + "_id": "bd7993c9c69feddfaeb7bdef", + "name": "Working With Decimals", + "dashedName": "waypoint-working-with-decimals", + "difficulty": "9.98151", + "description": [ + "", + "in JavaScript we can can work with decimal numbers", + "These decal numbers are known as floats.", + "Let's take a look at working with floats now" + ], + "tests": [ + "assert(multiply == 15, 'The result of multiply should be 3.75');", + "assert(divide == 2.25, 'The result of divide should be 2.25');" + ], + "challengeSeed": [ + "var multiply = 3.75 * 0;//equals 15", + "var divide = 9 / 0;//equals 2.25", + "", + "", + "", + "(function(y,z){return('multiply='+y+', divide='+z);})(multiply,divide);" + ], + "challengeType": 1 + }, + { + "_id": "bd7993c9c69feddfaeb8bdef", + "name": "An Array Of new Information", + "dashedName": "waypoint-an-array-of-new-information", + "difficulty": "9.9816", + "description": [ + "", + "In JavaScript we can store lists or collections of data in what are called arrays", + "Arrays are distinguished by the [ and ] around the data. Each piece of data is separated be a , ", + "Now let's create a new array called myArray with a string and a number with a , separating each one", + "Refer to the example if you get stuck", + "" + ], + "tests": [ + "assert(typeof(myArray) == 'object', 'myArray should be an array');", + "assert(typeof(myArray[0]) !== 'undefined' && typeof(myArray[0]) == 'string', 'The fist item in myArray should be a string');", + "assert(typeof(myArray[1]) !== 'undefined' && typeof(myArray[1]) == 'number', 'The second item in myArray should be a number');" + ], + "challengeSeed": [ + "//var array = ['John', 23];", + "", + "var myArray = [];", + "", + "", + "(function(z){return(z);})(myArray);" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb7bdef", + "name":"Nesting Arrays", + "dashedName":"waypoint-nesting-arrays", + "difficulty":"9.98161", + "description":[ + "", + "We are also able to create arrays within arrays. This technique is called nesting.", + "Let's now go create a nested array called myArray" + ], + "tests":[ + "assert((function(){if(typeof(myArray) !== 'undefined' && typeof(myArray) === 'object' && typeof(myArray[0]) !== 'undefined' && typeof(myArray) === 'object'){return(true);}else{return(false);}})(), 'myArray should contain at least one array');" + ], + "challengeSeed":[ + "var myArray = [];", + "", + "", + "if(typeof(myArray) !== 'undefined'){(function(){return(myArray);})();}" + ], + "challengeType": 1 + }, + { + "_id":"bg9997c9c79feddfaeb9bdef", + "name":"Accessing data with Indexes", + "dashedName":"waypoint-accessing-data-with-indexes", + "difficulty":"9.9817", + "description":[ + "", + "Once an array has been created we can access the data we have stored in them using indexes", + "Indexes are written in the same way as bracket notation that we covered earlier", + "Example:", + "", + "var array = [1,2,3];", + "array[0];//equals 1", + "var data = array[1];", + "", + "Create a var called data and set it to equal the first value of myArray" + ], + "tests":[ + "assert((function(){if(typeof(myArray) != 'undefined' && typeof(data) != 'undefined' && myArray[0] == data){return(true);}else{return(false);}})(), 'the variable data should equal the first value of myArray');" + ], + "challengeSeed":[ + "//var ourArray = [1,2,3]", + "//var ourData = ourArray[0]//equals 1", + "", + "var myArray = [1,2,3];", + "", + "", + "", + "if(typeof(myArray) != 'undefined' && typeof(data) != 'undefined'){(function(y,z){return('myArray = ' + JSON.stringify(y) + ', data = ' + JSON.stringify(z));})(myArray, data);}" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb8bdef", + "name":"Modifying Data With Indexes", + "dashedName":"waypoint-modifying-data-with-indexes", + "difficulty":"9.98171", + "description":[ + "", + "We are able to modify the data store in an array be using indexes", + "Example:", + "", + "var ourArray = [1,2,3];", + "ourArray[0] = 3;//ourArray equals [3,2,3]", + "", + "Now Let's modify myArray using an index", + "" + ], + "tests":[ + "assert((function(){if(typeof(myArray) != 'undefined' && myArray[0] == 3 && myArray[1] == 2 && myArray[2] == 3){return(true);}else{return(false);}})(), 'myArray should now be [3,2,3]');", + "assert((function(){if(editor.getValue().match(/[0]/g).length >= 2 && editor.getValue().match(/=/g).length >= 2){return(true);}else{return(false);}})(), 'You should be using indexes to modify the values in myArray');" + ], + "challengeSeed":[ + "//var ourArray = [1,2,3];", + "//ourArray[0] = 3;", + "", + "var myArray = [1,2,3];", + "", + "", + "", + "", + "if(typeof(myArray) != 'undefined'){(function(){return(myArray);})();}" + ], + "challengeType": 1 + }, + { + "_id": "bg9994c9c69feddfaeb9bdef", + "name": "Manipulating Arrays With pop()", + "dashedName": "waypoint-manipulating-arrays-with-pop", + "difficulty": "9.9818", + "description": [ + "", + "When and array has been defined we still have the ability to make changes to it afterwards", + "One common way in which we can manipulate the data in an array is through .pop() ", + " .pop() is used to \"pop\" a value from the end of an array. We can retrieve this value by preforming the pop in a variable declaration.", + "any type of variable can be \"popped\" from and array", + "Let's try .pop() now" + ], + "tests": [ + "assert((function(d){if(d[0] == 'John' && d[1] == 23 && d[2] == undefined){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23])');", + "assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return(true);}else{return(false);}})(removed), 'myArray should only have the first two values left([\"cat\"], 2)');" + ], + "challengeSeed": [ + "//var numbers = [1,2,3];", + "//console.log(numbers); //Gives [1,2,3]", + "//var removed = numbers.pop();", + "//console.log(numbers); //Gives [1,2]", + "//console.log(removed); //Gives 3", + "", + "var myArray = ['John', 23, ['cat', 2]];", + "var removed = _;//This should be ['cat', 2] and myArray should now be ['John', 23]", + "", + "", + "(function(y, z){return('myArray = ' + JSON.stringify(y) + ' & removed = ' + JSON.stringify(z));})(myArray, removed);" + ], + "challengeType": 1 + }, + { + "_id": "bg9995c9c69feddfaeb9bdef", + "name": "Manipulating Arrays With push()", + "dashedName": "waypoint-manipulating-arrays-with-push", + "difficulty": "9.9818", + "description": [ + "", + "Now that we've learn how to pop things from the end of the array, we need to learn how to push stuff back to the end", + "Let's take the code we had last time and push this value to the end: ['dog', 3] " + ], + "tests": [ + "assert((function(d){if(d[2] != undefined && d[0] == 'John' && d[1] == 23 && d[2][0] == 'dog' && d[2][1] == 3){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23, [\"dog\", 3]])');" + ], + "challengeSeed": [ + "var myArray = ['John', 23, ['cat', 2]];", + "var removed = myArray.pop();", + "//Add a ['dog', 3] to the end of myArray using push", + "", + "", + "(function(z){return('myArray = ' + JSON.stringify(z));})(myArray);" + ], + "challengeType": 1 + }, + { + "_id": "bg9996c9c69feddfaeb9bdef", + "name": "Manipulating Arrays With shift()", + "dashedName": "waypoint-manipulating-arrays-with-shift", + "difficulty": "9.9817", + "description": [ + "", + "Another common way in which we can manipulate the data in an array is through .shift() ", + " .shift() is used to \"shift\" a value from the start of an array. We can retrieve this value by preforming the shift in a variable declaration.", + "Let's try .shift() now" + ], + "tests": [ + "assert((function(d){if(d[0] == 23 && d[1][0] == 'dog' && d[1][1] == 3 && d[2] == undefined){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23])');", + "assert((function(d){if(d == 'John'){return(true);}else{return(false);}})(removed), 'Removed should contain \"John\"');" + ], + "challengeSeed": [ + "var myArray = ['John', 23, ['dog', 3]];", + "var removed = _;//This should be ['John'] and myArray should now be ['John', 23]", + "", + "", + "(function(y, z){return('myArray = ' + JSON.stringify(y) + ' & removed = ' + JSON.stringify(z));})(myArray, removed);" + ], + "challengeType": 1 + }, + { + "_id": "bg9997c9c69feddfaeb9bdef", + "name": "Manipulating Arrays With unshift()", + "dashedName": "waypoint-manipulating-arrays-with-unshift", + "difficulty": "9.9818", + "description": [ + "", + "Now that we've learned how to shift things from the start of the array, we need to learn how to unshift stuff back to the start", + "Let's take the code we had last time and unshift this value to the end: 'Paul' " + ], + "tests": [ + "assert((function(d){if(d[0].toLowerCase() == 'paul' && d[1] == 23 && d[2][0] != undefined && d[2][0] == 'dog' && d[2][1] != undefined && d[2][1] == 3){return(true);}else{return(false);}})(myArray), 'myArray should now have [\"Paul\", 23, [\"dog\", 3]])');" + ], + "challengeSeed": [ + "var myArray = ['John', 23, ['dog', 3]];", + "var removed = myArray.shift();//This should be 'John' and myArray should now be [23, ['dog', 3]]", + "//Add 'Paul' to the start of myArray", + "", + "", + "(function(y, z){return('myArray = ' + JSON.stringify(y));})(myArray);" + ], + "challengeType": 1 + }, + { + "_id":"bg9997c9c89feddfaeb9bdef", + "name":"Make it functional", + "dashedName":"waypoint-make-it-functional", + "difficulty":"9.9819", + "description":[ + "", + "In JavaScript we can divide up our code into separate and reusable parts called functions", + "here's and example of a function", + "", + "function functionName (a, b){", + " return(a + b);", + "}", + "", + "our function can be called like this", + "functionName();", + "Let's try creating and calling a function now called myFunction" + ], + "tests":[ + "assert((function(){if(typeof(f) !== 'undefined' && typeof(f) === 'number' && f === 9){return(true);}else{return(false);}})(), 'Your function should return the value of a + b');" + ], + "challengeSeed":[ + "var a = 4;", + "var b = 5;", + "//Don not modify the above!", + "//Create a function called myFunction that adds a and b", + "", + "", + "", + "", + "//Don't modify this!", + "if(typeof(myFunction) != 'undefined'){", + "var f=myFunction(a,b);", + "(function(){return(f);})();", + "}" + ], + "challengeType": 1 + }, + { + "_id":"bg9998c9c99feddfaeb9bdef", + "name":"I Object!", + "dashedName":"waypoint-i-object", + "difficulty":"9.9822", + "description":[ + "", + "A very important data type in javascript is the Object ", + " Objects a similar to arrays except that instead of using indexes to access and modify their data, Objects have what are called properties ", + "Here's a sample Object", + "", + "var cat = {", + " \"name\": \"Whiskers\",", + " \"legs\": 4,", + " \"tails\": 1,", + " \"enemies\": [\"Water\", \"Dogs\"]", + "};", + "", + "Objects are useful for storing data in a structured way or in a way that represents a real world object like a cat.", + "Let's try to make a Object that represents a dog called myDog!" + + ], + "tests":[ + "assert((function(z){if(z.hasOwnProperty('name') && z.name != undefined && typeof(z.name) == 'string'){return(true);}else{return(false);}})(myDog), 'myDog should contain the property name and it should be a string');", + "assert((function(z){if(z.hasOwnProperty('legs') && z.legs != undefined && typeof(z.legs) == 'number'){return(true);}else{return(false);}})(myDog), 'myDog should contain the property legs and it should be a number');", + "assert((function(z){if(z.hasOwnProperty('tails') && z.tails != undefined && typeof(z.tails) == 'number'){return(true);}else{return(false);}})(myDog), 'myDog should contain the property tails and it should be a number');", + "assert((function(z){if(z.hasOwnProperty('friends') && z.friends != undefined && Array.isArray(z.friends)){return(true);}else{return(false);}})(myDog), 'myDog should contain the property friends and it should be an array');" + ], + "challengeSeed":[ + "//var ourDog = {", + "// \"name\": \"Camper\"", + "// \"legs\": 4", + "// \"tails\": 1", + "// \"friends\": ['everything!']", + "//};", + "", + "/* add the name(string), legs(number), tails(number) and friends(array) properties to myDog.", + "You can set them to whatever you want!*/", + "", + "var myDog = {", + " ", + "};", + "", + "(function(z){return(z);})(myDog);" + ], + "challengeType": 1 + }, + { + "_id":"bg9999c9c99feddfaeb9bdef", + "name":"Manipulating Objects", + "dashedName":"waypoint-manipulating-objects", + "difficulty":"9.9823", + "description":[ + "", + "Now that we have an objects we need to know how to add and remove properties from it", + "We add properties to objects like this", + "myObject['myProperty'] = \"myValue\";", + "They can also be deleted like this", + "delete(myObject[\"myProperty\"]);", + "Let's add the property bark", + "" + ], + "tests":[ + "assert(myDog.bark != undefined, 'The property tails should have been deleted');", + "assert(myDog.tails == undefined, 'The property tails should have been deleted');" + ], + "challengeSeed":[ + "//var ourDog = {", + "//\"name\": \"Camper\"", + "//\"legs\": 4", + "//\"tails\": 1", + "//\"friends\": [\"everything!\"]", + "//};", + "", + "//Re-create myDog", + "", + "var myDog = {", + " \"name\": _,", + " \"legs\": _,", + " \"tails\": _,", + " \"friends\": []", + "};", + "", + "//Let's add the property age to myDog", + "", + "", + "//Now delete the property tails", + "", + "", + "(function(z){return(z);})(myDog);" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb5bdef", + "name":"Looping with for", + "dashedName":"waypoint-looping-with-for", + "difficulty":"9.9824", + "description":[ + "", + "Loops are a critical part of any program! The next few challenges", + "first we will be taking a look at the for loop", + "", + "var ourArray = [];", + "for(var i = 0; i < 5; i++){", + " ourArray.push(i);", "}", - "returnValue(secondToLastLetterOfLastName);" + "", + "ourArray now contains [0,1,2,3,4] ", + "Let's try getting a for loop to work by pushing values to an array" + ], + "tests":[ + "assert(editor.getValue().match(/for\\(/g), 'You should be using a for loop for this!');", + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" + ], + "challengeSeed":[ + "var myArray = [];", + "//Push the numbers 0-4 to myArray", + "", + "" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb1bdef", + "name":"Looping with while", + "dashedName":"waypoint-looping-with-while", + "difficulty":"9.9825", + "description":[ + "", + "Loops are a critical part of any program! The next few challenges", + "first we will be taking a look at the for loop", + "", + "var ourArray = [];", + "var i = 0;", + "while(i < 5){", + " ourArray.push(i);", + " i++;", + "}", + "", + "Let's try getting a for loop to work by pushing values to an array" + ], + "tests":[ + "assert(editor.getValue().match(/while\\(/g), 'You should be using a while loop for this!');", + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" + ], + "challengeSeed":[ + "var myArray = [];", + "//Push the numbers 0-4 to myArray", + "", + "" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb2bdef", + "name":"Looping with do while", + "dashedName":"waypoint-looping-with-do-while", + "difficulty":"9.9826", + "description":[ + "", + "Let's now take a look at the do - while loop", + "", + "var ourArray = [];", + "var i = 0;", + "do{", + " ourArray.push(i);", + " i++;", + "}while(i<5);", + "", + "A do - while has a very special difference when compared to the for and while loops. The do while loop is guaranteed to execute preform it's action once regardless of whether or not the condition inside the while is met!", + "Let's try getting a do - while loop to work by pushing values to an array" + ], + "tests":[ + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');", + "assert((function(){if(editor.getValue().match(/do/g) && editor.getValue(/while/g).match()){return(true);}else{return(false);}})(), 'You should be using a do while loop for this!');" + ], + "challengeSeed":[ + "var myArray = [];", + "//Push the numbers 0-4 to myArray", + "", + "" ], "challengeType": 1 } From 003805d8349009869011e53799793a4bd75df91c Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Thu, 16 Jul 2015 11:06:04 +0100 Subject: [PATCH 09/13] Added start of the random number challenges --- seed/challenges/basic-javascript.json | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 993ce01944..7bf51368b5 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -848,6 +848,68 @@ "" ], "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb9bdef", + "name":"Random Numbers", + "dashedName":"waypoint-random-numbers", + "difficulty":"9.9827", + "description":[ + "", + "Random numbers are a very useful for creating random behaviours and games", + "Javascript has a Math.random() method that can generate a random decimal number", + "Let's have a go of Math.random() now be getting myFunction to return a random number" + ], + "tests":[ + "assert(typeof(myFunction()) === 'number', 'myFunction should return a random number');", + "assert((myFunction()+''). match(/\\./g), 'The number returned by myFunction should be a decimal');", + "assert(editor.getValue().match(/Math\\.random/g).length >= 2, 'You should be using Math.random to generate the random decimal number');" + ], + "challengeSeed":[ + "", + "function myFunction(){", + " //Change the 0 to Math.random()", + " return(0);", + "}", + "", + "(function(){return(myFunction());})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb1bdef", + "name":"Random Whole Numbers", + "dashedName":"waypoint-random-whole-numbers", + "difficulty":"9.9828", + "description":[ + "", + "While it's great that we can create random decimal numbers it's a lot more useful to generate a random whole number", + "To achieve this we can multiply the random number by ten and use the Math.floor() to convert the decimal number to a whole number", + "This technique gives us a whole number between zero and nine", + "Let's give this technique a go now" + ], + "tests":[], + "challengeSeed":[ + "function myFunction(){", + " //Make myFunction return a random number between zero and nine instead of a float", + "}", + "", + "(function(){return(myFunction());})();" + ], + "challengeType": 1 + }, + { + "_id":"", + "name":"Random Whole Numbers In a Range", + "dashedName":"waypoint-random-whole-numbers-in-a-range", + "difficulty":"9.9829", + "description":[ + "", + "" + ], + "tests":[], + "challengeSeed":[], + "challengeType": 1 } ] } From ead5c19d6e9e8a8e0fb165b26e723f71437e5ce9 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Fri, 24 Jul 2015 00:35:50 +0100 Subject: [PATCH 10/13] Ready JavaScript Curriculum --- seed/challenges/basic-javascript.json | 713 ++++++++++++++++---------- 1 file changed, 437 insertions(+), 276 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 9a50f07b5c..9fb5129929 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -19,9 +19,9 @@ "Try creating one of each now." ], "tests":[ - "assert(editor.getValue().match(/(\\/\\*)...../g), 'Make sure you have at least one \/\\* \\*\/ style comment that has at least three letters in it');", + "assert(editor.getValue().match(/(\\/\\*)...../g), 'Make sure you have at least one \/\\* \\*\/ style comment that has at least five letters in it');", "assert(editor.getValue().match(/(\\*\\/)/g), 'Make sure that you close the coment with a \\*\/');", - "assert(editor.getValue().match(/(\\/\\/)...../g), 'Make sure that there is at least one \\/\\/ style comment with at least three letters in it');" + "assert(editor.getValue().match(/(\\/\\/)...../g), 'Make sure that there is at least one \\/\\/ style comment with at least five letters in it');" ], "challengeSeed":[ @@ -69,8 +69,7 @@ "Look at the ourName example if you get stuck." ], "tests": [ - "assert(typeof(myName) == 'string', \"You're new variable should be a string\");", - "assert(myName.length > 0, \"You're string should have something in it!\");" + "assert((function(){/**/if(typeof(myName) !== 'undefined' && typeof(myName) == 'string' && myName.length > 0){return(true);}else{return(false);}/**/})(), 'myName should be a string that contains at least one character in it');" ], "challengeSeed": [ "// var ourName = \"Free Code Camp\";", @@ -78,34 +77,8 @@ "// You can ignore this.", "// We use this to show you the value of your variable in your output box.", "// We'll learn about functions soon.", - "(function(v){return(v);})(ourName);" - ], - "challengeType": 1 - }, - { - "_id": "bd7123c9c442eddfaeb5bdef", - "name": "Define Your Name", - "dashedName": "waypoint-define-your-name", - "difficulty": "9.9802", - "description": [ "", - "In this challenge we are going to take a look at strings.", - "Strings are a data type for words and sentences", - "Now we are going to set the value of myName to your name by typing your name in quotes.", - "Currently myName is empty. Type in your name and hit the submit button.", - "Look at the ourName example if you get stuck." - ], - "tests": [ - "assert(typeof(myName) == 'string', 'The variable myName should be a string');", - "assert(myName.length > 0, 'Give the string myName a value');" - ], - "challengeSeed": [ - "// ourName = \"Free Code Camp\";", - "myName = \"\";", - "// You can ignore this.", - "// We use this to show you the value of your variable in your output box.", - "// We'll learn about functions soon.", - "(function(v){return(v);})(myName);" + "if(typeof(myName) !== 'undefined'){(function(v){return(v);})(myName);}" ], "challengeType": 1 }, @@ -113,7 +86,7 @@ "_id": "bd7123c9c444eddfaeb5bdef", "name": "Define Your First and Last Name", "dashedName": "waypoint-define-your-first-and-last-name", - "difficulty": "9.9804", + "difficulty": "9.9802", "description": [ "", "Programs will almost always have several different variables that are used to keep track of several different pieces of data", @@ -121,64 +94,19 @@ "You can assign these variables to be equal to your first and last names respectively." ], "tests": [ - "assert(typeof(myFirstName) == 'string', 'myFirstName should be set to a string');", - "assert(typeof(myLastName) == 'string', 'myLastName should be set to a string');", - "assert(myFirstName.length > 0, 'myFirstName Should not be empty');", - "assert(myLastName.length > 0, 'myLastName should not be empty');", - "assert(typeof(myName) == 'string', 'The variable myName should be a string');", - "assert(myName.length > 0, 'Give the string myName a value');" + "assert((function(){if(typeof(myFirstName) !== 'undefined' && typeof(myFirstName) == 'string' && myFirstName.length > 0){return(true);}else{return(false);}})(), 'myFirstName should be a string with a least one character in it');", + "assert((function(){if(typeof(myLastName) !== 'undefined' && typeof(myLastName) == 'string' && myLastName.length > 0){return(true);}else{return(false);}})(), 'myLastName should be a string with a least one character in it');" ], "challengeSeed": [ "// ourName = \"Free Code Camp\";", "// var ourFirstName = \"Free\";", "// var ourLastName = \"Code Camp\";", "", - "var myName = \"\";", - "", "", "// You can ignore this.", "// We use this to show you the value of your variable in your output box.", "// We'll learn about functions soon.", - "(function(v){return(v);})(myName);" - ], - "challengeType": 1 - }, - { - "_id": "bd7123c9c445eddfaeb5bdef", - "name": "Combine Two Strings into One String", - "dashedName": "waypoint-combine-two-variables-into-one-string", - "difficulty": "9.9805", - "description": [ - "Make a variable called myName by adding the string of your first name to the string of your last name.", - "Strings can be combined in a process called concatenation.", - "We are now going to take the two variables myFirstName and myLastName and assign them values", - "Once we have given values to our two variables we can now concatenate them together with a space in between them", - "Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in lower camel case. An example of lower camel case is: lowerCamelCase.", - "Look at the ourName example if you get stuck." - ], - "tests": [ - "assert(typeof(myFirstName) == 'string', 'myFirstName should be set to a string');", - "assert(typeof(myLastName) == 'string', 'myLastName should be set to a string');", - "assert(myFirstName.length > 0, 'myFirstName Should not be empty');", - "assert(myLastName.length > 0, 'myLastName should not be empty');", - "assert(typeof(myName) == 'string', 'myName should be a string');", - "assert(myName.length > 0, \"You're string should have something in it!\");", - "assert((/\\s+/).test(myName) == true, 'myName shuold contain a space');" - ], - "challengeSeed": [ - "// var ourFirstName = \"Free\";", - "// var ourLastName = \"Code Camp\";", - "// var ourName = ourFirstName + \" \" + ourLastName;", - "", - "var myFirstName = \"\";", - "var myLastName = \"\";", - "var myName;", - "", - "", - "// You can ignore this.", - "// We use this to show you the value of your variable in your output box.", - "// We'll learn about functions soon.", - "(function(v){return(v);})(myName);" + "if(typeof(myFirstName) !== 'undefined' && typeof(myLastName) !== 'undefined'){(function(y,z){return(y + ', ' + z);})(myFirstName, myLastName);}" ], "challengeType": 1 }, @@ -193,7 +121,7 @@ "For example, if we created a variable var firstName = \"Julie\", we could find out how long the string \"Julie\" is by using the firstName.length property." ], "tests": [ - "assert(lastNameLength == 4, 'lastNameLength should have a length of 4');" + "(function(){if(typeof(lastNameLength) != 'undefined' && typeof(lastNameLength) == 'number' && lastNameLength == 4){return(true);}else}{return(false);}}, 'lastNameLength should be equal to four')()" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -209,7 +137,7 @@ "// You can ignore this.", "// We use this to show you the value of your variable in your output box.", "// We'll learn about functions soon.", - "(function(v){return(v);})(lastNameLength);" + "if(typeof(lastNameLength) != 'undefined')(function(v){return(v);})(lastNameLength);}" ], "challengeType": 1 }, @@ -226,7 +154,7 @@ "Try looking at the firstLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "assert(firstLetterOfLastName == 'C', 'The first letter of firstLetterOfLastName should be a C');" + "assert((function(){if(typeof(firstLetterOfLastName) != 'undefined' && typeof(firstLetterOfLastName) == 'string' && firstLetterOfLastName == 'C'){return(true);}else{return(false);}})(), 'The first letter of firstLetterOfLastName should be a C');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -253,11 +181,11 @@ "description": [ "Just like the last lesson where we used Bracket Notation to access the first letter we can use the same method to get the letters ar other positions", "Don't forget that computers start counting at 0 so the first letter is actually the zeroth one", - "Let's now try to set thirdLetterOfLastName to equal the third letter of the lastName variable", + "Let's now try to set thirdLetterOfLastName to equal the third letter of the lastName variable", "Try looking at the secondLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "assert(thirdLetterOfLastName == 'e', thirdLetterOfLastName);" + "assert(thirdLetterOfLastName == 'e', 'The third last letter of lastName should be an e');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -289,7 +217,8 @@ "Try looking at the lastLetterOfLastName variable declaration if you get stuck." ], "tests": [ - "assert(lastLetterOfLastName == 'n', 'lastLetterOfLastName should be n');" + "assert(lastLetterOfLastName == 'n', 'lastLetterOfLastName should be n');", + "assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the last letter');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -318,7 +247,8 @@ "Try looking at the lastLetterOfLastName variable declaration if you get stuck." ], "tests": [ - "assert(secondToLastLetterOfLastName == 'e', 'secondToLastLetterOfLastName should be e');" + "assert(secondToLastLetterOfLastName == 'e', 'secondToLastLetterOfLastName should be e');", + "assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the third last letter');" ], "challengeSeed": [ "var firstName = \"Madeline\";", @@ -335,35 +265,123 @@ "challengeType": 1 }, { - "_id": "bd7993c9c69feddfaeb6bdef", - "name": "Magical Maths", - "dashedName": "waypoint-magical-maths", - "difficulty": "9.9814", + "_id": "bh1111c1c11feddfaeb3bdef", + "name": "Magical Maths Addition", + "dashedName": "waypoint-magical-maths-addition", + "difficulty": "9.98141", "description": [ "", "In JavaScript whole numbers (called integers) can be really easily to preform mathematical functions", "Let's try a few of the most commonly used ones now", "We use + for addition", - "We use - for subtraction", - "We use * for multiplication", - "We use / for division", - "Replace the _ with correct number to achieve the result in the comment." + "Replace the 0 with correct number to achieve the result in the comment." ], "tests": [ - "assert(add==20, 'The result of the sum in add should be 20');", - "assert(subtract==12, 'The result of the sum in add should be 12');", - "assert(multiply==80, 'The result of the sum in add should be 80');", - "assert(divide==2, 'The result of the sum in add should be 2');" + "assert((function(){if(add == 20 && editor.getValue().match(/\\+/g)){return(true);}else{return(false);}})(), 'Add should be the result of a sum and be equal to 20');" ], "challengeSeed": [ - "var add = 10 + _;//equals 20", - "var subtract = 45 - _;//equals 12", - "var multiply = 8 * _;//equals 80", - "var divide = 66 / _;//equals 2", + "var add = 10 + 0;//equals 20", "", "", "", - "(function(w,x,y,z){return('add='+w+', subtract='+x+', multiply='+y+', divide='+z);})(add,subtract,multiply,divide);" + "(function(z){return('add='+z);})(add);" + ], + "challengeType": 1 + }, + { + "_id": "bh1111c1c11feddfaeb4bdef", + "name": "Magical Maths Subtraction", + "dashedName": "waypoint-magical-maths-subtraction", + "difficulty": "9.98142", + "description": [ + "", + "In JavaScript whole numbers (called integers) can be really easily to preform mathematical functions", + "Let's try a few of the most commonly used ones now", + "We use - for subtraction", + "Replace the 0 with correct number to achieve the result in the comment." + ], + "tests": [ + "assert((function(){if(subtract == 12 && editor.getValue().match(/\\-/g)){return(true);}else{return(false);}})(), 'Subtract should be the result of a sum and be equal to 12');" + ], + "challengeSeed": [ + "var subtract = 45 - 0;//equals 12", + "", + "", + "", + "(function(z){return('subtract='+z);})(subtract);" + ], + "challengeType": 1 + }, + { + "_id": "bh1111c1c11feddfaeb5bdef", + "name": "Magical Maths Multiplication", + "dashedName": "waypoint-magical-maths-multiplication", + "difficulty": "9.98143", + "description": [ + "", + "In JavaScript whole numbers (called integers) can be really easily to preform mathematical functions", + "Let's try a few of the most commonly used ones now", + "We use * for multiplication", + "Replace the 0 with correct number to achieve the result in the comment." + ], + "tests": [ + "assert((function(){if(multiply == 80 && editor.getValue().match(/\\*/g)){return(true);}else{return(false);}})(), 'Multiply should be the result of a sum and be equal to 80');" + ], + "challengeSeed": [ + "var multiply = 8 * 0;//equals 80", + "", + "", + "", + "(function(z){return('multiply='+z);})(multiply);" + ], + "challengeType": 1 + }, + { + "_id": "bh1111c1c11feddfaeb6bdef", + "name": "Magical Maths Division", + "dashedName": "waypoint-magical-maths-division", + "difficulty": "9.9814", + "description": [ + "", + "In JavaScript whole numbers (called integers) can be really easily to preform mathematical functions", + "Let's try a few of the most commonly used ones now", + "We use / for division", + "Replace the 0 with correct number to achieve the result in the comment." + ], + "tests": [ + "assert((function(){if(divide == 2 && editor.getValue().match(/\\//g)){return(true);}else{return(false);}})(), 'Divide should be the result of a sum and be equal to 2');" + ], + "challengeSeed": [ + "var divide = 66 / 0;//equals 2", + "", + "", + "", + "(function(z){return('divide='+z);})(divide);" + ], + "challengeType": 1 + }, + { + "_id": "bh1111c1c11feddfaeb4bdef", + "name": "Creating Decimals", + "dashedName": "waypoint-creating-decimals", + "difficulty": "9.9815", + "description": [ + "", + "in JavaScript we can can work with decimal numbers", + "These decal numbers are known as floats.", + "Let's create a float now called myFloat and give it a value" + ], + "tests": [ + "assert((function(){if(typeof(myFloat) != 'undefined' && typeof(myFloat) == 'number' && editor.getValue().match(/\\./g).length >=2){return(true);}else{return(false);}})(), 'myFloat should be a decimal point number');" + ], + "challengeSeed": [ + "//var ourFloat = 5.7", + "//Create a number with a decimal point here called myFloat", + "", + "", + "", + "", + "if(typeof(myFloat) != 'undefined'){(function(z){return(z);})(myFloat);}" ], "challengeType": 1 }, @@ -371,7 +389,7 @@ "_id": "bd7993c9c69feddfaeb7bdef", "name": "Working With Decimals", "dashedName": "waypoint-working-with-decimals", - "difficulty": "9.9815", + "difficulty": "9.98151", "description": [ "", "in JavaScript we can can work with decimal numbers", @@ -379,20 +397,16 @@ "Let's take a look at working with floats now" ], "tests": [ - "assert(add == 13.5, 'The result of add should be 13.5');", - "assert(subtract == 7.25, 'The result of subtract should be 7.25');", "assert(multiply == 15, 'The result of multiply should be 3.75');", "assert(divide == 2.25, 'The result of divide should be 2.25');" ], "challengeSeed": [ - "var add = 9 + _;//equals 13.5", - "var subtract = 12 - _;//equals 7.25", - "var multiply = 3.75 * _;//equals 15", - "var divide = 9 / _;//equals 2.25", + "var multiply = 3.75 * 0;//equals 15", + "var divide = 9 / 0;//equals 2.25", "", "", "", - "(function(w,x,y,z){return('add='+w+', subtract='+x+', multiply='+y+', divide='+z);})(add,subtract,multiply,divide);" + "(function(y,z){return('multiply='+y+', divide='+z);})(multiply,divide);" ], "challengeType": 1 }, @@ -405,18 +419,17 @@ "", "In JavaScript we can store lists or collections of data in what are called arrays", "Arrays are distinguished by the [ and ] around the data. Each piece of data is separated be a , ", - "Now let's create a new array called myArray with a string , a number and a array with a , separating each one", + "Now let's create a new array called myArray with a string and a number with a , separating each one", "Refer to the example if you get stuck", "" ], "tests": [ "assert(typeof(myArray) == 'object', 'myArray should be an array');", - "assert(myArray[0] !== undefined && typeof(myArray[0]) == 'string', 'The fist item in myArray should be a string');", - "assert(myArray[1] !== undefined && typeof(myArray[1]) == 'number', 'The second item in myArray should be a number');", - "assert(myArray[2] !== undefined && typeof(myArray[2]) == 'object', 'The third item in myArray should be an array');" + "assert(typeof(myArray[0]) !== 'undefined' && typeof(myArray[0]) == 'string', 'The fist item in myArray should be a string');", + "assert(typeof(myArray[1]) !== 'undefined' && typeof(myArray[1]) == 'number', 'The second item in myArray should be a number');" ], "challengeSeed": [ - "//var array = ['John', 23, [2, 'cat']];", + "//var array = ['John', 23];", "", "var myArray = [];", "", @@ -425,11 +438,97 @@ ], "challengeType": 1 }, + { + "_id":"bh1111c1c11feddfaeb7bdef", + "name":"Nesting Arrays", + "dashedName":"waypoint-nesting-arrays", + "difficulty":"9.98161", + "description":[ + "", + "We are also able to create arrays within arrays. This technique is called nesting.", + "Let's now go create a nested array called myArray" + ], + "tests":[ + "assert((function(){if(typeof(myArray) !== 'undefined' && typeof(myArray) === 'object' && typeof(myArray[0]) !== 'undefined' && typeof(myArray) === 'object'){return(true);}else{return(false);}})(), 'myArray should contain at least one array');" + ], + "challengeSeed":[ + "var myArray = [];", + "", + "", + "if(typeof(myArray) !== 'undefined'){(function(){return(myArray);})();}" + ], + "challengeType": 1 + }, + { + "_id":"bg9997c9c79feddfaeb9bdef", + "name":"Accessing data with Indexes", + "dashedName":"waypoint-accessing-data-with-indexes", + "difficulty":"9.9817", + "description":[ + "", + "Once an array has been created we can access the data we have stored in them using indexes", + "Indexes are written in the same way as bracket notation that we covered earlier", + "Example:", + "", + "var array = [1,2,3];", + "array[0];//equals 1", + "var data = array[1];", + "", + "Create a var called data and set it to equal the first value of myArray" + ], + "tests":[ + "assert((function(){if(typeof(myArray) != 'undefined' && typeof(data) != 'undefined' && myArray[0] == data){return(true);}else{return(false);}})(), 'the variable data should equal the first value of myArray');" + ], + "challengeSeed":[ + "//var ourArray = [1,2,3]", + "//var ourData = ourArray[0]//equals 1", + "", + "var myArray = [1,2,3];", + "", + "", + "", + "if(typeof(myArray) != 'undefined' && typeof(data) != 'undefined'){(function(y,z){return('myArray = ' + JSON.stringify(y) + ', data = ' + JSON.stringify(z));})(myArray, data);}" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c11feddfaeb8bdef", + "name":"Modifying Data With Indexes", + "dashedName":"waypoint-modifying-data-with-indexes", + "difficulty":"9.98171", + "description":[ + "", + "We are able to modify the data store in an array be using indexes", + "Example:", + "", + "var ourArray = [1,2,3];", + "ourArray[0] = 3;//ourArray equals [3,2,3]", + "", + "Now Let's modify myArray using an index", + "" + ], + "tests":[ + "assert((function(){if(typeof(myArray) != 'undefined' && myArray[0] == 3 && myArray[1] == 2 && myArray[2] == 3){return(true);}else{return(false);}})(), 'myArray should now be [3,2,3]');", + "assert((function(){if(editor.getValue().match(/[0]/g).length >= 2 && editor.getValue().match(/=/g).length >= 2){return(true);}else{return(false);}})(), 'You should be using indexes to modify the values in myArray');" + ], + "challengeSeed":[ + "//var ourArray = [1,2,3];", + "//ourArray[0] = 3;", + "", + "var myArray = [1,2,3];", + "", + "", + "", + "", + "if(typeof(myArray) != 'undefined'){(function(){return(myArray);})();}" + ], + "challengeType": 1 + }, { "_id": "bg9994c9c69feddfaeb9bdef", "name": "Manipulating Arrays With pop()", "dashedName": "waypoint-manipulating-arrays-with-pop", - "difficulty": "9.9817", + "difficulty": "9.9818", "description": [ "", "When and array has been defined we still have the ability to make changes to it afterwards", @@ -527,38 +626,6 @@ ], "challengeType": 1 }, - { - "_id":"bg9997c9c79feddfaeb9bdef", - "name":"Manipulating Arrays Indexes", - "dashedName":"waypoint-manipulating-arrays-indexes", - "difficulty":"9.9818", - "description":[ - "", - "With Arrays, we can access and modify the data inside them using indexes much like we did with strings. The major difference between using indexes with arrays versus using them in strings is that you cannot modify data in a string using and index.", - "In Arrays though we are freely allowed to change values in an array.", - "Let's have a go and accessing the last item in myArray and changing the middle value tp 25 ", - "Take a look at the commented out example above if you get stuck" - ], - "tests":[ - "assert((function(a){if(a[0] != undefined && a[0] == 'Paul' && a[1] != undefined && a[1] == 25 && a[2][0] != undefined && a[2][0] == 'dog' && a[2][1] != undefined && a[2][1] == 3){return(true);}else{return(false);}})(myArray), 'myArray should be [\"John\", \"David\",\"Paul\"]');", - "assert((function(l){if(l[0] != undefined && l[0] == 'dog' && l[1] != undefined && l[1] == 3){return(true);}else{return(false);}})(last), 'The last variable in myArray should be [\"dog\", 3]');" - ], - "challengeSeed":[ - "//var ourArray = ['Alpha', 'Beta', 'Gamma'];", - "//ourArray[0];//the first item in the array is 'Alpha'", - "//ouArray[1] = 'Omega';//The second item int the array is nom Omega instead of Beta", - "", - "var myArray = ['Paul', 23, ['dog', 3]];", - "var last = _;//Set this to be the last variable in the array using an index", - "", - "//Now set the second item in the Array to be 25 using an index'", - "", - "", - "", - "(function(y,z){return('myArray = ' + JSON.stringify(y) + ', last = ' + JSON.stringify(z));})(myArray, last);" - ], - "challengeType": 1 - }, { "_id":"bg9997c9c89feddfaeb9bdef", "name":"Make it functional", @@ -569,123 +636,31 @@ "In JavaScript we can divide up our code into separate and reusable parts called functions", "here's and example of a function", "", - "function funcitonName (one, two ,three){", - " /*Some Code*/", + "function functionName (a, b){", + " return(a + b);", "}", "", "our function can be called like this", "functionName();", - "Let's try creating and calling a function now." + "Let's try creating and calling a function now called myFunction" ], "tests":[ - "assert(f==data);" + "assert((function(){if(typeof(f) !== 'undefined' && typeof(f) === 'number' && f === 9){return(true);}else{return(false);}})(), 'Your function should return the value of a + b');" ], "challengeSeed":[ - "//var ourData = 'function called!';", - "//function ourFunction(ourData) {/*ourData is being passed to this function as an argument*/", - "//return(data);", - "//}", - "", - "var data = 'Function Called!';", - "", - "//Create a function called myFunction that takes data as an argument and returns it like the example above", - "", + "var a = 4;", + "var b = 5;", + "//Don not modify the above!", + "//Create a function called myFunction that adds a and b", "", "", "", "", "//Don't modify this!", - "var f=myFunction(data);", - "(function(){var f=myFunction(data);return(f);})('');" - ], - "challengeType": 1 - }, - { - "_id":"bg9997c9c99feddfaeb9bdef", - "name":"Doing things inside functions", - "dashedName":"waypoint-doing-things-inside-functions", - "difficulty":"9.982", - "description":[ - "", - "A function that takes the value you give it and returns it isn't very useful! So now let's get our functions to do something!", - "Starting from where we were last time let's make our function revers whatever we give it by chaining .split('') , .reverse() and .join('') " - ], - "tests":[ - "assert(f==data.split('').reverse().join(''), 'myFunction should now return the reversed version of data (!dellaC noitcnuF)');" - ], - "challengeSeed":[ - "//You can reverse strings like this", - "//var notReversed = 'String';", - "//var reversed = notReversed.split('').reverse().join('');", - "", - "var data = 'Function Called!';", - "", - "function myFunction(data){", - " ", - " return(data);", - "}", - "", - "", - "", - "//Don't modify this!", - "var f=myFunction(data);", - "(function(f){return(f);})(f);" - ], - "challengeType": 1 - }, - { - "_id":"bg9997c9c99feddfaeb9bdef", - "name":"Keeping In The Scope Of Things", - "dashedName":"waypoint-keeping-in-the-scope-of-things", - "difficulty":"9.9821", - "description":[ - "", - "All variables are contained in something called a scope .", - "A Scope defines where are variable can be accessed.", - "All variables created outside any functions exist in what is called the global scope ", - "All variables are container or are scope to inside that function.", - "", - "var variable = 'Global Scope'", - "function test(){", - " return(variable);", - "}", - "test();//Returns Global Scope", - "", - "function change(){", - " variable = 'test';", - " return(variable);", - "}", - "", - "change();//Returns test", - "variable //equals Global Scope", - "", - "", - "Let's give this a go!" - ], - "tests":[ - "assert(Global == access(Global), 'access should return your Global var');", - "assert(Global != localChange(Global), 'localChange should return your Global var');" - ], - "challengeSeed":[ - "//Create Your global variable with any value here", - "var Global = _;", - "", - "//Make access() return you global variable", - "function access(){", - " ", - "}", - "", - "access();", - "", - "//Pass you global variable into localChange and modify it within the function", - "function localChange(){", - " ", - "}", - "", - "//Don't forget to call localChange here and pass your global variable", - "", - "", - "(function(x,y,z){return('access returns: ' + y(x) + ' & localChange returns: ' + z(x));})(Global, access, localChange);" + "if(typeof(myFunction) != 'undefined'){", + "var f=myFunction(a,b);", + "(function(){return(f);})();", + "}" ], "challengeType": 1 }, @@ -875,38 +850,224 @@ "challengeType": 1 }, { - "_id":"bh1111c1c11feddfaeb3bdef", - "name":"Looping with recursion", - "dashedName":"waypoint-looping-with-recursion", + "_id":"bh1111c1c11feddfaeb9bdef", + "name":"Random Numbers", + "dashedName":"waypoint-random-numbers", "difficulty":"9.9827", "description":[ "", - "The next method of looping that we'll examine is called recursion", - "A recursive function (a function that uses recursion) is a function that calls itself until a predefined condition is met", - "", - "var ourArray = [];", - "var i = 0;", - "function loop(){", - " ourArray.push(i);", - " i++;", - " if(i < 5){", - " loop()", - " }", - "}", - "", - "ourArray now contains [0,1,2,3,4] ", - "Let's try getting recursion to work by pushing values to an array" + "Random numbers are a very useful for creating random behaviours and games", + "Javascript has a Math.random() method that can generate a random decimal number", + "Let's have a go of Math.random() now be getting myFunction to return a random number" ], "tests":[ - "assert((function(){if(!editor.getValue().match(/do/g) && !editor.getValue().match(/while/g) && !editor.getValue().match(/for/g)){return(true);}else{return(false);}})(), 'You should be using recursion for this!')", - "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" + "assert(typeof(myFunction()) === 'number', 'myFunction should return a random number');", + "assert((myFunction()+''). match(/\\./g), 'The number returned by myFunction should be a decimal');", + "assert(editor.getValue().match(/Math\\.random/g).length >= 2, 'You should be using Math.random to generate the random decimal number');" ], "challengeSeed":[ - "var myArray = [];", - "//Push the numbers 0-4 to myArray", "", + "function myFunction(){", + " //Change the 0 to Math.random()", + " return(0);", + "}", + "", + "(function(){return(myFunction());})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb1bdef", + "name":"Random Whole Numbers", + "dashedName":"waypoint-random-whole-numbers", + "difficulty":"9.9828", + "description":[ + "", + "While it's great that we can create random decimal numbers it's a lot more useful to generate a random whole number", + "To achieve this we can multiply the random number by ten and use the Math.floor() to convert the decimal number to a whole number", + "This technique gives us a whole number between zero and nine", + "Example:", + "Math.floor(Math.random()*10);", + "Let's give this technique a go now" + ], + "tests":[ + "assert(typeof(myFunction()) == 'number', 'The result of myFunction should be a number');", + "assert(editor.getValue().match(/Math.random/g), 'You should be using Math.random to create a random number');", + "assert(!(''+myFunction()).match(/\\./g), 'You should have multiplied the result of Math.random but 10 to make it a number that\\'s greater then zero');", + "assert(editor.getValue().match(/Math.floor/g), 'You should use Math.floor to remove the decimal part of the number');" + ], + "challengeSeed":[ + "function myFunction(){", + " //Make myFunction return a random number between zero and nine instead of a float", + " return(Math.random());", + "}", + "", + "(function(){return(myFunction());})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb2bdef", + "name":"Random Whole Numbers In a Range", + "dashedName":"waypoint-random-whole-numbers-in-a-range", + "difficulty":"9.9829", + "description":[ + "", + "We can use a certain mathematical expression to get a random number between between twp numbers.", + "Math.floor(Math.random() * (max - min + 1)) + min", + "By using this we can control the output of the random number.", "" ], + "tests":[ + "assert(myFunction() >= min, 'The random number that\\'s generated by myFunction should be greater than or equal to the minimum number');", + "assert(myFunction() <= max, 'The random number that\\'s generated by myFunction should be less than or equal to the maximum number');", + "assert((function(){if(editor.getValue().match(/max/g).length >= 2 && editor.getValue().match(/min/g).length >= 3 && editor.getValue().match(/Math.floor/g) && editor.getValue().match(/Math.random/g)){return(true);}else{return(false);}})(), 'You should be using the function given in the description to calculate the random in number in a range');" + ], + "challengeSeed":[ + " var min = 0;", + " var max = 12;", + "function myFunction(){", + " //Make myFunction return a random number between zero and nine instead of a float", + " return(Math.random());", + "}", + "", + "(function(){return(myFunction());})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb3bdef", + "name":"If Else Statements", + "dashedName":"waypoint-if-else-statements", + "difficulty":"9.983", + "description":[ + "", + "We can use if statements in JavaScript to only execute code if a certain condition is met", + "if statements require some sort of boolean condition evaluate", + "Example:", + "if(1==2){", + " return(true);", + "}", + "else{", + " return(false);", + "}", + "Let's have a go of using if statements now by making a coin-flip game", + "Create an if else statement to return heads if the flip var is zero and to return tails if it's not" + ], + "tests":[ + "assert((function(){if(myFunction() == 'heads' || myFunction() == 'tails'){return(true);}else{return(false);}})(), 'myFunction should either return heads or tails');", + "assert(editor.getValue().match(/if/g).length >= 3, 'You should have created a new if statement');", + "assert(editor.getValue().match(/else/g).length >= 2, 'You should have created a new else statement');" + ], + "challengeSeed":[ + "function myFunction(){", + " var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;", + " //Create and if else statement here to return heads if flip is 0 otherwise return false", + " ", + "}", + "", + "(function(){return(myFunction());})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb6bdef", + "name":"An Intro To RegEx", + "dashedName":"waypoint-an-intro-to-regex", + "difficulty":"9.984", + "description":[ + "", + "RegEx is a powerful tool we can use to find certain words or patterns in strings", + "RegEx can look difficult at first but there's not much to getting it working", + "If we wanted to find the number of times the word \"the\" occured in the string \"The dog chased the cat\" We could use the following RegEx:", + "\/the+\/gi", + "Let's break this down a bit", + "\"The\" is the pattern we want to match", + "\"+\" means we are looking for one or more occurrences of this pattern", + "\"g\" means that it searhces the whole string", + "\"i\" means that we are ignoring the case(upper or lower) of what we are looking for", + "Let's try finding the word and in the string \"John and Alan went to the shop and got some milk\" by replacing the .+ in the currnet RegEx with something that will find the word \"and\" and count how many times it occurs" + ], + "tests":[ + "assert(test==2, 'You\\'re RegEx should have found two occurances of the word \"and\"');", + "assert(editor.getValue().match(/\\/and\\+\\/gi/), 'You should have used this RegEx to find the word \"and\"');" + ], + "challengeSeed":[ + "var test = (function(){", + " var testString = \"John and Alan went to the shop and got some milk\";", + "", + "//Do Not Modify Above", + "", + " var expression = /.+/gi;", + "", + "//Do Not Modify Below", + "", + " return(testString.match(expression).length);", + "})();(function(){return(test);})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb7bdef", + "name":"Finding Numbers", + "dashedName":"waypoint-finding-numbers", + "difficulty":"9.985", + "description":[ + "", + "We can use special selectors in RegEx to select a particular type of value", + "One such selector is the digit selector \\d which is used to grab the numbers in a string", + "It is used like this:", + "/\\d+/g", + "" + ], + "tests":[ + "assert(test === 2, 'Your RegEx should have found two numbers in the testString');", + "assert(editor.getValue().match(/\\/\\\\d\\+\\//gi), 'You should be using the following expression /\\d+/gi to find the numbers in the testString');" + ], + "challengeSeed":[ + "var test = (function(){", + " var testString = \"There's 3 cats but 4 dogs.\"", + "", + "//Do Not Modify Above", + "", + " var expression = /.+/gi;", + "", + "//Do Not Modify Below", + "", + " return(testString.match(expression).length);", + "})();(function(){return(test);})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb8bdef", + "name":"Finding WhiteSpace", + "dashedName":"waypoint-finding-whitespace", + "difficulty":"9.987", + "description":[ + "", + "We can also use selectors like \\s to find spaces in a string", + "It is used like this:", + "/\\s+/g", + "" + ], + "tests":[ + "assert(test === 7, 'Your RegEx should have found seven spaces in the testString');", + "assert(editor.getValue().match(/\\/\\\\s\\+\\//gi), 'You should be using the following expression /\\s+/gi to find the spaces in the testString');" + ], + "challengeSeed":[ + "var test = (function(){", + " var testString = \"How many spaces are there in this sentance.\";", + "", + "//Do Not Modify Above", + "", + " var expression = /.+/gi;", + "", + "//Do Not Modify Below", + "", + " return(testString.match(expression).length);", + "})();(function(){return(test);})();" + ], "challengeType": 1 } ] From a24ef288b4d00cea5366e32ae0c6f477100f3967 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Fri, 24 Jul 2015 00:38:13 +0100 Subject: [PATCH 11/13] Ready Js Curriculum Added Regex, Random Numbers and If else Challenges --- seed/challenges/basic-javascript.json | 167 +++++++++++++++++++++++++- 1 file changed, 163 insertions(+), 4 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 7bf51368b5..9fb5129929 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -886,12 +886,20 @@ "While it's great that we can create random decimal numbers it's a lot more useful to generate a random whole number", "To achieve this we can multiply the random number by ten and use the Math.floor() to convert the decimal number to a whole number", "This technique gives us a whole number between zero and nine", + "Example:", + "Math.floor(Math.random()*10);", "Let's give this technique a go now" ], - "tests":[], + "tests":[ + "assert(typeof(myFunction()) == 'number', 'The result of myFunction should be a number');", + "assert(editor.getValue().match(/Math.random/g), 'You should be using Math.random to create a random number');", + "assert(!(''+myFunction()).match(/\\./g), 'You should have multiplied the result of Math.random but 10 to make it a number that\\'s greater then zero');", + "assert(editor.getValue().match(/Math.floor/g), 'You should use Math.floor to remove the decimal part of the number');" + ], "challengeSeed":[ "function myFunction(){", " //Make myFunction return a random number between zero and nine instead of a float", + " return(Math.random());", "}", "", "(function(){return(myFunction());})();" @@ -899,16 +907,167 @@ "challengeType": 1 }, { - "_id":"", + "_id":"bh1111c1c12feddfaeb2bdef", "name":"Random Whole Numbers In a Range", "dashedName":"waypoint-random-whole-numbers-in-a-range", "difficulty":"9.9829", "description":[ "", + "We can use a certain mathematical expression to get a random number between between twp numbers.", + "Math.floor(Math.random() * (max - min + 1)) + min", + "By using this we can control the output of the random number.", "" ], - "tests":[], - "challengeSeed":[], + "tests":[ + "assert(myFunction() >= min, 'The random number that\\'s generated by myFunction should be greater than or equal to the minimum number');", + "assert(myFunction() <= max, 'The random number that\\'s generated by myFunction should be less than or equal to the maximum number');", + "assert((function(){if(editor.getValue().match(/max/g).length >= 2 && editor.getValue().match(/min/g).length >= 3 && editor.getValue().match(/Math.floor/g) && editor.getValue().match(/Math.random/g)){return(true);}else{return(false);}})(), 'You should be using the function given in the description to calculate the random in number in a range');" + ], + "challengeSeed":[ + " var min = 0;", + " var max = 12;", + "function myFunction(){", + " //Make myFunction return a random number between zero and nine instead of a float", + " return(Math.random());", + "}", + "", + "(function(){return(myFunction());})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb3bdef", + "name":"If Else Statements", + "dashedName":"waypoint-if-else-statements", + "difficulty":"9.983", + "description":[ + "", + "We can use if statements in JavaScript to only execute code if a certain condition is met", + "if statements require some sort of boolean condition evaluate", + "Example:", + "if(1==2){", + " return(true);", + "}", + "else{", + " return(false);", + "}", + "Let's have a go of using if statements now by making a coin-flip game", + "Create an if else statement to return heads if the flip var is zero and to return tails if it's not" + ], + "tests":[ + "assert((function(){if(myFunction() == 'heads' || myFunction() == 'tails'){return(true);}else{return(false);}})(), 'myFunction should either return heads or tails');", + "assert(editor.getValue().match(/if/g).length >= 3, 'You should have created a new if statement');", + "assert(editor.getValue().match(/else/g).length >= 2, 'You should have created a new else statement');" + ], + "challengeSeed":[ + "function myFunction(){", + " var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;", + " //Create and if else statement here to return heads if flip is 0 otherwise return false", + " ", + "}", + "", + "(function(){return(myFunction());})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb6bdef", + "name":"An Intro To RegEx", + "dashedName":"waypoint-an-intro-to-regex", + "difficulty":"9.984", + "description":[ + "", + "RegEx is a powerful tool we can use to find certain words or patterns in strings", + "RegEx can look difficult at first but there's not much to getting it working", + "If we wanted to find the number of times the word \"the\" occured in the string \"The dog chased the cat\" We could use the following RegEx:", + "\/the+\/gi", + "Let's break this down a bit", + "\"The\" is the pattern we want to match", + "\"+\" means we are looking for one or more occurrences of this pattern", + "\"g\" means that it searhces the whole string", + "\"i\" means that we are ignoring the case(upper or lower) of what we are looking for", + "Let's try finding the word and in the string \"John and Alan went to the shop and got some milk\" by replacing the .+ in the currnet RegEx with something that will find the word \"and\" and count how many times it occurs" + ], + "tests":[ + "assert(test==2, 'You\\'re RegEx should have found two occurances of the word \"and\"');", + "assert(editor.getValue().match(/\\/and\\+\\/gi/), 'You should have used this RegEx to find the word \"and\"');" + ], + "challengeSeed":[ + "var test = (function(){", + " var testString = \"John and Alan went to the shop and got some milk\";", + "", + "//Do Not Modify Above", + "", + " var expression = /.+/gi;", + "", + "//Do Not Modify Below", + "", + " return(testString.match(expression).length);", + "})();(function(){return(test);})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb7bdef", + "name":"Finding Numbers", + "dashedName":"waypoint-finding-numbers", + "difficulty":"9.985", + "description":[ + "", + "We can use special selectors in RegEx to select a particular type of value", + "One such selector is the digit selector \\d which is used to grab the numbers in a string", + "It is used like this:", + "/\\d+/g", + "" + ], + "tests":[ + "assert(test === 2, 'Your RegEx should have found two numbers in the testString');", + "assert(editor.getValue().match(/\\/\\\\d\\+\\//gi), 'You should be using the following expression /\\d+/gi to find the numbers in the testString');" + ], + "challengeSeed":[ + "var test = (function(){", + " var testString = \"There's 3 cats but 4 dogs.\"", + "", + "//Do Not Modify Above", + "", + " var expression = /.+/gi;", + "", + "//Do Not Modify Below", + "", + " return(testString.match(expression).length);", + "})();(function(){return(test);})();" + ], + "challengeType": 1 + }, + { + "_id":"bh1111c1c12feddfaeb8bdef", + "name":"Finding WhiteSpace", + "dashedName":"waypoint-finding-whitespace", + "difficulty":"9.987", + "description":[ + "", + "We can also use selectors like \\s to find spaces in a string", + "It is used like this:", + "/\\s+/g", + "" + ], + "tests":[ + "assert(test === 7, 'Your RegEx should have found seven spaces in the testString');", + "assert(editor.getValue().match(/\\/\\\\s\\+\\//gi), 'You should be using the following expression /\\s+/gi to find the spaces in the testString');" + ], + "challengeSeed":[ + "var test = (function(){", + " var testString = \"How many spaces are there in this sentance.\";", + "", + "//Do Not Modify Above", + "", + " var expression = /.+/gi;", + "", + "//Do Not Modify Below", + "", + " return(testString.match(expression).length);", + "})();(function(){return(test);})();" + ], "challengeType": 1 } ] From efa5d769c25904eb336087b57bc941a36544ff5f Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Thu, 23 Jul 2015 18:44:16 -0700 Subject: [PATCH 12/13] QA first dozen html challenges --- seed/challenges/html5-and-css.json | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/seed/challenges/html5-and-css.json b/seed/challenges/html5-and-css.json index b58e74ff8d..d434232d16 100644 --- a/seed/challenges/html5-and-css.json +++ b/seed/challenges/html5-and-css.json @@ -8,11 +8,10 @@ "dashedName": "waypoint-say-hello-to-html-elements", "difficulty": 0.001, "description": [ - "Welcome to Free Code Camp's first coding challenge! Click on the button below for further instructions.", - "Awesome. Now you can read the rest of this challenge's instructions.", + "Welcome to Free Code Camp's first coding challenge!", "You can edit code in your text editor, which we've embedded into this web page.", "Do you see the code in your text editor that says <h1>Hello</h1>? That's an HTML element.", - "Most HTML elements have an opening tag and a closing tag. Opening tags look like this: <h1>. Closing tags look like this: </h1>. Note that the only difference between opening and closing tags is that closing tags have a slash after their opening angle bracket.", + "Most HTML elements have an opening tag and a closing tag. Opening tags look like this: <h1>. Closing tags look like this: </h1>. Note that the only difference between opening tags and closing tags is that closing tags have a slash after their opening angle bracket.", "Once you've completed each challenge, and all its tests are passing, the \"Go to my next challenge\" button will become enabled. Click it - or press control and enter at the same time - to advance to the next challenge.", "To enable the \"Go to my next challenge\" button on this exercise, change your h1 tag's text to say \"Hello World\" instead of \"Hello\"." ], @@ -240,11 +239,10 @@ "dashedName": "waypoint-fill-in-the-blank-with-placeholder-text", "difficulty": 0.007, "description": [ - "Replace the text inside your p element with the first few words of the provided \"Kitty Ipsum\" text.", "Web developers traditionally use \"Lorem Ipsum\" text as placeholder text. It's called \"Lorem Ipsum\" text because those are the first two words of a famous passage by Cicero of Ancient Rome.", "\"Lorem Ipsum\" text has been used as placeholder text by typesetters since the 16th century, and this tradition continues on the web.", "Well, 5 centuries is long enough. Since we're building a CatPhotoApp, let's use something called \"Kitty Ipsum\"!", - "Here are the first few words of \"Kitty Ipsum\" text, which you can copy and paste into the right position: Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff." + "Replace the text inside your p element with the first few words of this \"Kitty Ipsum\" text: Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff." ], "tests": [ "assert.isTrue((/Kitty(\\s)+ipsum(\\s)+dolor/gi).test($('p').text()), 'Your p element should contain the first few words of the provided \"Kitty Ipsum\" text.')" @@ -528,9 +526,9 @@ "dashedName": "waypoint-change-the-font-size-of-an-element", "difficulty": 0.013, "description": [ - "Create a second p element. Then, inside your <style> element, set the \"font-size\" of all p elements to 16 pixels.", + "Create a second p element with the following Kitty Ipsum text: Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.", + "Then, inside your <style> element, set the \"font-size\" of all p elements to 16 pixels.", "Font size is controlled by the \"font-size\" CSS attribute, like this: h1 { font-size: 30px; }.", - "First, create a second p element with the following Kitty Ipsum text: Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.", "See if you can figure out how to give both of your p elements the font-size of 16 pixels (16px). You can do this inside the same <style> tag that we created for your \"red-text\" class." ], "tests": [ @@ -676,15 +674,15 @@ "dashedName": "waypoint-specify-how-fonts-should-degrade", "difficulty": 0.016, "description": [ - "Make all your h2 elements use \"Lobster\" as their font family, but degrade to the \"Monospace\" font when the \"Lobster\" font isn't available.", - "You can leave \"Lobster\" your h2 element's font-family, and have it \"degrade\" to a different font when \"Lobster\" isn't available.", + "There are several default fonts that are available in all browsers. These include \"Monospace\", \"Serif\" and \"Sans-Serif\". Leave \"Lobster\" as the font-family for your h2 elements. Make them \"degrade\" to \"Monospace\" when \"Lobster\" isn't available.", "For example, if you wanted an element to use the \"Helvetica\" font, but also degrade to the \"Sans-Serif\" font when \"Helvetica\" wasn't available, you could use this CSS style: p { font-family: Helvetica, Sans-Serif; }.", - "There are several default fonts that are available in all browsers. These include \"Monospace\", \"Serif\" and \"Sans-Serif\". See if you can set your h2 elements to use \"Lobster\" and degrade to \"Monospace\".", - "Now try commenting out your call to Google Fonts, so that the \"Lobster\" font isn't available. Notice how it degrades to the \"Monospace\" font." + "Now comment out your call to Google Fonts, so that the \"Lobster\" font isn't available. Notice how it degrades to the \"Monospace\" font." ], "tests": [ "assert($('h2').css('font-family').match(/^\"?lobster/i), 'Your h2 element should use the font \"Lobster\".')", - "assert($('h2').css('font-family').match(/lobster\"?,monospace/i), 'Your h2 element should degrade to the font \"Monospace\" when \"Lobster\" is not available.')" + "assert($('h2').css('font-family').match(/lobster.*,.*monospace/i), 'Your h2 element should degrade to the font \"Monospace\" when \"Lobster\" is not available.')", + "assert(new RegExp('', 'gi').test(editor), 'Be sure to close your comment by deleting all trailing comment tags, i.e. -->.')" ], "challengeSeed": [ "", From 890bd8cd9c3a9dc864fce501fef2541aff474b00 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Thu, 23 Jul 2015 22:24:51 -0700 Subject: [PATCH 13/13] additional refactor of HTML challenges --- seed/challenges/html5-and-css.json | 83 +++++++++++++++--------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/seed/challenges/html5-and-css.json b/seed/challenges/html5-and-css.json index d434232d16..dbb0f037fe 100644 --- a/seed/challenges/html5-and-css.json +++ b/seed/challenges/html5-and-css.json @@ -732,7 +732,6 @@ "dashedName": "waypoint-add-images-to-your-website", "difficulty": 0.017, "description": [ - "Use an img element to add the image http://bit.ly/fcc-kittens to your website.", "You can add images to your website by using the img element, and point to an specific image's URL using the src attribute.", "An example of this would be <img src=\"www.your-image-source.com/your-image.jpg\"/>. Note that in most cases, img elements are self-closing.", "Try it with this image: http://bit.ly/fcc-kittens." @@ -788,9 +787,9 @@ "dashedName": "waypoint-size-your-images", "difficulty": 0.018, "description": [ - "Create a class called smaller-image and use it to resize the image so that it's only 100 pixels wide.", "CSS has an attribute called width that controls an element's width. Just like with fonts, we'll use pixels(px) to specify the image's width.", - "For example, if we wanted to create a CSS class called \"larger-image\" that gave HTML elements a width of 500 pixels, we'd use: <style> .larger-image { width: 500px; } </style>." + "For example, if we wanted to create a CSS class called \"larger-image\" that gave HTML elements a width of 500 pixels, we'd use: <style> .larger-image { width: 500px; } </style>.", + "Create a class called smaller-image and use it to resize the image so that it's only 100 pixels wide." ], "tests": [ "assert($('img').hasClass('smaller-image'), 'Your img element should have the class \"smaller-image\".')", @@ -844,9 +843,9 @@ "dashedName": "waypoint-add-borders-around-your-elements", "difficulty": 0.019, "description": [ - "Create a class called \"thick-green-border\" that puts a 10-pixel-wide green border with a style of \"solid\" around an HTML element, and apply that class to your cat photo.", "CSS borders have attributes like style, color and width.", - "For example, if we wanted to create a red, 5 pixel border around an HTML element, we could use this class: <style> .thin-red-border { border-color: red; border-width: 5px; border-style: solid; } </style>." + "For example, if we wanted to create a red, 5 pixel border around an HTML element, we could use this class: <style> .thin-red-border { border-color: red; border-width: 5px; border-style: solid; } </style>.", + "Create a class called \"thick-green-border\" that puts a 10-pixel-wide green border with a style of \"solid\" around an HTML element, and apply that class to your cat photo." ], "tests": [ "assert($('img').hasClass('smaller-image'), 'Your img element should have the class \"smaller-image\".')", @@ -907,9 +906,9 @@ "dashedName": "waypoint-add-rounded-corners-with-a-border-radius", "difficulty": 0.020, "description": [ - "Give your cat photo a border-radius of 10 pixels.", "Your cat photo currently has sharp corners. We can round out those corners with a CSS attribute called border-radius.", - "You can specify a border-radius with pixels. This will affect how rounded the corners are. Add this attribute to your thick-green-border class and set it to 10 pixels." + "You can specify a border-radius with pixels. This will affect how rounded the corners are. Add this attribute to your thick-green-border class and set it to 10 pixels.", + "Give your cat photo a border-radius of 10 pixels." ], "tests": [ "assert($('img').hasClass('thick-green-border'), 'Your image element should have the class \"thick-green-border\".')", @@ -973,8 +972,8 @@ "dashedName": "waypoint-make-circular-images-with-a-border-radius", "difficulty": 0.021, "description": [ - "Give your cat photo a border-radius of 50%.", - "In addition to pixels, you can also specify a border-radius using a percentage." + "In addition to pixels, you can also specify a border-radius using a percentage.", + "Give your cat photo a border-radius of 50%." ], "tests": [ "assert(parseInt($('img').css('border-top-left-radius')) > 48, 'Your image should have a border radius of 50 percent, making it perfectly circular.')", @@ -1038,10 +1037,11 @@ "dashedName": "waypoint-link-to-external-pages-with-anchor-elements", "difficulty": 0.022, "description": [ - "Create an a element, or \"anchor element\", that links to http://catphotoapp.com and has \"cat photos\" as its link text, or \"anchor text\".", - "Here's a diagram of an a element. In this case, it's used in the middle of a paragraph element, which means your link will appear in the middle of your sentence.", + "a elements or \"anchor\" elements, are used to link to content outside of the current page.", + "Here's a diagram of an a element. In this case, the a element is used in the middle of a paragraph element, which means the link will appear in the middle of a sentence.", "a diagram of how anchor tags are composed with the same text as on the following line", - "Here's an example: <p>Here's a <a href='http://freecodecamp.com'> link to Free Code Camp</a> for you to follow.</p>." + "Here's an example: <p>Here's a <a href='http://freecodecamp.com'> link to Free Code Camp</a> for you to follow.</p>.", + "Create an a element that links to http://catphotoapp.com and has \"cat photos\" as its \"anchor text\"." ], "tests": [ "assert((/cat photos/gi).test($('a').text()), 'Your a element should have the anchor text of \"cat photos\"')", @@ -1108,10 +1108,10 @@ "dashedName": "waypoint-wrap-an-anchor-element-within-a-paragraph", "difficulty": 0.023, "description": [ - "Now wrap your a element within a new p element so that the surrounding paragraph says \"click here for cat photos\", but where only \"cat photos\" is a link - the rest is plain text.", "Again, here's a diagram of an a element for your reference:", "a diagram of how anchor tags are composed with the same text as on the following line", - "Here's an example: <p>Here's a <a href='http://freecodecamp.com'> link to Free Code Camp</a> for you to follow.</p>." + "Here's an example: <p>Here's a <a href='http://freecodecamp.com'> link to Free Code Camp</a> for you to follow.</p>.", + "Now wrap your a element within a new p element so that the surrounding paragraph says \"click here for cat photos\", but where only \"cat photos\" is a link - the rest is plain text." ], "tests": [ "assert($('a').attr('href').match(/catphotoapp.com/gi).length > 0, 'You need an a element that links to \"catphotoapp.com\".')", @@ -1183,10 +1183,9 @@ "dashedName": "waypoint-make-dead-links-using-the-hash-symbol", "difficulty": 0.024, "description": [ - "Use the hash symbol (#) to turn your a element's link into a dead link.", "Sometimes you want to add a elements to your website before you know where they will link.", "This is also handy when you're changing the behavior of a link using jQuery, which we'll learn about later.", - "Replace your a element's href attribute with a hash symbol to turn it into a dead link." + "Replace your a element's href attribute with a hash symbol (#) to turn it into a dead link." ], "tests": [ "assert($('a').attr('href') === '#', 'Your anchor element should be a dead link with a href attribute set to \"#\".')" @@ -1253,7 +1252,6 @@ "dashedName": "waypoint-turn-an-image-into-a-link", "difficulty": 0.025, "description": [ - "Wrap your img element inside an a element with a dead link.", "You can make elements into links by wrapping them within an a element.", "Wrap your image within an a element. Here's an example: <a href='#'><img src='http://bit.ly/fcc-kittens2'/></a>.", "Remember to use the hash symbol (#) as your a element's href property in order to turn it into a dead link.", @@ -1327,11 +1325,11 @@ "dashedName": "waypoint-add-alt-text-to-an-image-for-accessibility", "difficulty": 0.026, "description": [ - "Add an alt attribute with the text \"A cute orange cat lying on its back\" to our cat photo.", "alt attributes, also known as \"alt text\", are what browsers will display if they fail to load the image. alt attributes are also important for blind or visually impaired users to understand what an image portrays. Search engines also look at alt attributes.", "In short, every image should have an alt attribute!", "alt attributes are a useful way to tell people (and web crawlers like Google) what is pictured in a photo. It's extremely important for helping blind or visually impaired people understand the content of your website.", - "You can add an alt attribute right in the img element like this: <img src=\"www.your-image-source.com/your-image.jpg\" alt=\"your alt text\"/>." + "You can add an alt attribute right in the img element like this: <img src=\"www.your-image-source.com/your-image.jpg\" alt=\"your alt text\"/>.", + "Add an alt attribute with the text \"A cute orange cat lying on its back\" to our cat photo." ], "tests": [ "assert($('img').filter(function(){ return /cat/gi.test(this.alt) }).length > 0, 'Your image element should have an alt attribute set to \"A cute orange cat lying on its back\".')" @@ -1399,10 +1397,10 @@ "dashedName": "waypoint-create-a-bulleted-unordered-list", "difficulty": 0.027, "description": [ - "Replace your p elements with an unordered list of three things that cats love.", "HTML has a special element for creating unordered lists, or bullet point-style lists.", "Unordered lists start with a <ul> element. Then they contain some number of <li> elements.", - "For example: <ul><li>milk</li><li>cheese</li></ul> would create a bulleted list of \"milk\" and \"cheese\"." + "For example: <ul><li>milk</li><li>cheese</li></ul> would create a bulleted list of \"milk\" and \"cheese\".", + "Replace your p elements with an unordered list of three things that cats love." ], "tests": [ "assert($('ul').length > 0, 'Create a ul element.')", @@ -1472,10 +1470,10 @@ "dashedName": "waypoint-create-an-ordered-list", "difficulty": 0.028, "description": [ - "Create an ordered list of the top 3 things cats hate the most.", "HTML has a special element for creating ordered lists, or numbered-style lists.", "Ordered lists start with a <ol> element. Then they contain some number of <li> elements.", - "For example: <ol><li>hydrogen</li><li>helium</li></ol> would create a numbered list of \"hydrogen\" and \"helium\"." + "For example: <ol><li>hydrogen</li><li>helium</li></ol> would create a numbered list of \"hydrogen\" and \"helium\".", + "Create an ordered list of the top 3 things cats hate the most." ], "tests": [ "assert($('ul').length > 0, 'You should have an ul element on your page.')", @@ -1552,9 +1550,10 @@ "dashedName": "waypoint-create-a-text-field", "difficulty": 0.029, "description": [ - "Now we'll create a web form. Create a text input under your lists.", + "Now let's create a web form.", "Text inputs are a convenient way to get input from your user.", - "You can create one like this: <input type='text'>. Note that input elements are self-closing." + "You can create one like this: <input type=\"text\">. Note that input elements are self-closing.", + "Create an input element of type \"text\" below your lists." ], "tests": [ "assert($('input').length > 0, 'Your app should have a text field input element.')" @@ -1630,9 +1629,9 @@ "dashedName": "waypoint-add-placeholder-text-to-a-text-field", "difficulty": 0.030, "description": [ - "Set the placeholder value of your text input to \"cat photo URL\".", "Your placeholder text is what appears in your text input before your user has inputed anything.", - "You can create placeholder text like so: <input type='text' placeholder='this is placeholder text'>." + "You can create placeholder text like so: <input type='text' placeholder='this is placeholder text'>.", + "Set the placeholder value of your text input to \"cat photo URL\"." ], "tests": [ "assert($('input[placeholder]').length > 0, 'Add a placeholder attribute text input element.')", @@ -1710,9 +1709,9 @@ "dashedName": "waypoint-create-a-form-element", "difficulty": 0.031, "description": [ - "Wrap your text field in a form element. Add the action=\"/submit-cat-photo\" attribute to this form element.", "You can build web forms that actually submit data to a server using nothing more than pure HTML. You can do this by specifying an action on your form element.", - "For example: <form action=\"/url-where-you-want-to-submit-form-data\"></form>." + "For example: <form action=\"/url-where-you-want-to-submit-form-data\"></form>.", + "Wrap your text field in a form element. Add the action=\"/submit-cat-photo\" attribute to this form element." ], "tests": [ "assert($('form') && $('form').children('input') && $('form').children('input').length > 0, 'Wrap your text input element within a form element.')", @@ -1792,9 +1791,9 @@ "dashedName": "waypoint-add-a-submit-button-to-a-form", "difficulty": 0.032, "description": [ - "Add a submit button to your form element with type \"submit\" and \"Submit\" as its text.", "Let's add a submit button to your form. Clicking this button will send the data from your form to the URL you specified with your form's action attribute.", - "Here's an example submit button: <button type='submit'>this button submits the form</button>." + "Here's an example submit button: <button type='submit'>this button submits the form</button>.", + "Add a submit button to your form element with type \"submit\" and \"Submit\" as its text." ], "tests": [ "assert($('form').children('button').length > 0, 'Your form should have a button inside it.')", @@ -1876,9 +1875,9 @@ "dashedName": "waypoint-use-html5-to-require-a-field", "difficulty": 0.033, "description": [ - "Make your text input a \"required\" field, so that your user can't submit the form without completing this field.", "You can require specific form fields so that your user will not be able to submit your form until he or she has filled them out.", - "For example, if you wanted to make a text input field required, you can just add the word \"required\" within your input element, you would use: <input type='text' required>." + "For example, if you wanted to make a text input field required, you can just add the word \"required\" within your input element, you would use: <input type='text' required>.", + "Make your text input a \"required\" field, so that your user can't submit the form without completing this field." ], "tests": [ "assert($('input').prop('required'), 'Your text input element should have the \"required\" attribute.')" @@ -1958,12 +1957,12 @@ "dashedName": "waypoint-create-a-set-of-radio-buttons", "difficulty": 0.034, "description": [ - "Add to your form a pair of radio buttons. Each radio button should be wrapped within its own label element. They should share a common name attribute. One should have the option of \"indoor\" and the other should have the option of \"outdoor\".", "You can use radio buttons for questions where you want the user to only give you one answer.", "Radio buttons are a type of input.", "Each of your radio buttons should be wrapped within its own label elements.", "All related radio buttons should have the same name attribute.", - "Here's an example of a radio button: <label><input type='radio' name='indoor-outdoor'> Indoor</label>." + "Here's an example of a radio button: <label><input type='radio' name='indoor-outdoor'> Indoor</label>.", + "Add to your form a pair of radio buttons. Each radio button should be wrapped within its own label element. They should share a common name attribute. One should have the option of \"indoor\" and the other should have the option of \"outdoor\"." ], "tests": [ "assert($('input[type=\"radio\"]').length > 1, 'Your page should have two radio button elements.')", @@ -2051,9 +2050,9 @@ "dashedName": "waypoint-create-a-set-of-checkboxes", "difficulty": 0.035, "description": [ - "Add to your form a set of three checkbox elements. Each checkbox should be wrapped within its own label element. All three should share the name attribute of \"personality\".", "Forms commonly use checkbox inputs for questions that may have more than one answer.", - "For example: <label><input type='checkbox' name='personality'> Loving</label>." + "For example: <label><input type='checkbox' name='personality'> Loving</label>.", + "Add to your form a set of three checkbox elements. Each checkbox should be wrapped within its own label element. All three should share the name attribute of \"personality\"." ], "tests": [ "assert($('input[type=\"checkbox\"]').length > 2, 'Your page should have three checkbox elements.')", @@ -2138,9 +2137,9 @@ "dashedName": "waypoint-check-radio-buttons-and-checkboxes-by-default", "difficulty": 0.037, "description": [ - "Set the first of your radio buttons and the first of your checkboxes to both be checked by default.", - "You set a checkbox or radio button to be checked by default using the checked attribute.", - "To do this, just add the word \"checked\" to the inside of an input element. For example, <input type='radio' name='test-name' checked>." + "You can set a checkbox or radio button to be checked by default using the checked attribute.", + "To do this, just add the word \"checked\" to the inside of an input element. For example, <input type='radio' name='test-name' checked>.", + "Set the first of your radio buttons and the first of your checkboxes to both be checked by default." ], "tests": [ "assert($('input[type=\"radio\"]').prop('checked'), 'Your first radio button on your form should be checked by default.');", @@ -2226,11 +2225,11 @@ "dashedName": "waypoint-wrap-many-elements-within-a-single-div-element", "difficulty": 0.038, "description": [ - "Wrap your \"Things cats love\" and \"Things cats hate\" lists all within a single div element.", "The div element, or \"Division\" element, is a general purpose container for other elements.", "The div element is probably the most commonly used HTML element of all. It's useful for passing the CSS of its own class declarations down to all the elements that it contains.", "Just like any other non-self-closing element, you can open a div element with <div> and close it on another line with </div>.", - "Try putting your opening div tag above your \"Things cats love\" p element and your closing div tag after your closing ol tag so that both of your lists are within one div." + "Try putting your opening div tag above your \"Things cats love\" p element and your closing div tag after your closing ol tag so that both of your lists are within one div.", + "Wrap your \"Things cats love\" and \"Things cats hate\" lists all within a single div element." ], "tests": [ "assert($('div').children('ol').length > 0, 'Wrap your ol element inside your div element.')",