Initlal commit
This commit is contained in:
commit
ef856c31a3
|
@ -0,0 +1,14 @@
|
|||
// I get it, you're curious,
|
||||
// but it's OK if you don't understand what's going on in here, you'll learn it in time.
|
||||
|
||||
const abTroubleshoot = require("./troubleshooting");
|
||||
|
||||
const result = abTroubleshoot();
|
||||
|
||||
if(result === 2) {
|
||||
console.log("Congrats! You got the correct answer");
|
||||
} else if(typeof result === 'number') {
|
||||
console.log(`You returned the number ${result}, the result should be the number 2`);
|
||||
} else {
|
||||
console.log(`You returned string "${result}", the result should be the number 2`);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* ===== Troubleshooting =====
|
||||
* The function below should log the number 2, however it does not,
|
||||
* see if you can fix it!
|
||||
* Be sure to fix it in the spirit of the code, do not hard code the result.
|
||||
*/
|
||||
|
||||
function troubleshooting() {
|
||||
const a = 1;
|
||||
const b = 1;
|
||||
|
||||
let result;
|
||||
|
||||
// Edit between these lines
|
||||
// =================================
|
||||
result = "a" + "b";
|
||||
|
||||
// =================================
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Do not change this
|
||||
module.exports = troubleshooting;
|
|
@ -0,0 +1,57 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>repl.it</title>
|
||||
<link href="style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Be sure to enable the "developer" tools! (It's the wrench icon in replit)</p>
|
||||
<script src="script.js"></script>
|
||||
|
||||
<script>
|
||||
// Don't worry about this code here, just checking your results :)
|
||||
// I get it, you're curious,
|
||||
// but it's OK if you don't understand what's going on in here, you'll learn it in time.
|
||||
|
||||
let numCorrect = 0;
|
||||
let numChecked = 0;
|
||||
|
||||
const result = numberChecker();
|
||||
console.log(`You entered: ${number}, and got result: ${result}`);
|
||||
console.log("\n\n\n Test Results: \n")
|
||||
|
||||
function checkNumberChecker(num) {
|
||||
number = num;
|
||||
const result = numberChecker();
|
||||
if ((result === true && number >= 10) ||
|
||||
(result === false && number < 10)) {
|
||||
numCorrect++;
|
||||
console.log(`If I enter ${number}, the result is ${result}. This is correct!`);
|
||||
} else {
|
||||
console.error(`I entered "${number}", and got "${result}" as a result, I should have gotten "${number >= 10}" instead`);
|
||||
}
|
||||
|
||||
numChecked++
|
||||
console.log("\n");
|
||||
}
|
||||
|
||||
checkNumberChecker(2)
|
||||
checkNumberChecker(12)
|
||||
checkNumberChecker(6)
|
||||
checkNumberChecker(10)
|
||||
checkNumberChecker(9)
|
||||
|
||||
if (numCorrect === numChecked) {
|
||||
console.log("You've passed all the tests, continue to the next exercise!")
|
||||
} else {
|
||||
console.log(`You have failed ${numChecked - numCorrect} out of ${numChecked}, please try again`);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* The code below tells the browser to ask you for a number
|
||||
* then if that number is `6`, it returns `true` otherwise it returns `false`
|
||||
*
|
||||
* Change this code so it returns `true` when the number is greater than or equal to 10, and false if it is less than 10
|
||||
*/
|
||||
|
||||
number = Number(prompt("enter a number"));
|
||||
|
||||
function numberChecker() {
|
||||
if(number === 6) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
const { a, b, c, d, e } = require("./math");
|
||||
|
||||
if (a === 9) {
|
||||
console.log("'a' is correct!")
|
||||
} else {
|
||||
console.log(`'a' is incorrect, got ${a}, expected 9`)
|
||||
}
|
||||
console.log("\n");
|
||||
|
||||
if (b === 66) {
|
||||
console.log("'b' is correct!")
|
||||
} else {
|
||||
console.log(`'b' is incorrect, got ${b}, expected 66`)
|
||||
}
|
||||
console.log("\n");
|
||||
|
||||
if (c === 1) {
|
||||
console.log("'c' is correct!")
|
||||
} else {
|
||||
console.log(`'c' is incorrect, got ${c}, expected 1`)
|
||||
}
|
||||
console.log("\n");
|
||||
|
||||
if (d === -8) {
|
||||
console.log("'d' is correct!")
|
||||
} else {
|
||||
console.log(`'d' is incorrect, got ${d}, expected -8`)
|
||||
}
|
||||
console.log("\n");
|
||||
|
||||
if (e === 68) {
|
||||
console.log("'e' is correct!")
|
||||
console.log("\n Congrats! You may move onto the next exercise")
|
||||
} else {
|
||||
console.log(`'e' is incorrect, got ${e}, expected 68`)
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Lets do some math!
|
||||
* Some rules first:
|
||||
* - Replace the strings to the right of the = with the math expression they describe.
|
||||
* - Do not manually enter the answers to the equations. For example, `const a = 9` would be incorrect as 9 is the answer to the equation you're being asked to write out
|
||||
*/
|
||||
|
||||
const a = "one plus eight"
|
||||
const b = "22 times three"
|
||||
const c = "the *remainder* of 5/4"
|
||||
const d = "the variable 'a' minus 17"
|
||||
const e = "the sum of the previous four variables"
|
||||
|
||||
module.exports = {a, b, c, d, e}
|
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
- After each step, run the code to make sure your code still works!
|
||||
|
||||
- If your code fails to run, or you see a "ReferenceError" in the console, review your code and make sure you have completed all of the objectives.
|
||||
|
||||
- Don't forget you can put "console.log" anywhere to see what your values are at any time.
|
||||
|
||||
===== Step 1: =====
|
||||
Look at the code below and make a prediction of what the output will be.
|
||||
|
||||
After making your prediction, press 'Run' at the top and look at the output in the console. If you were surprised by anything, go back and look at the code to see what's going on.
|
||||
|
||||
*/
|
||||
|
||||
// code to be deleted
|
||||
const birthYear = 1948;
|
||||
const thisYear = 1965;
|
||||
const firstName = "Carlos";
|
||||
const lastName = "Stevenson";
|
||||
|
||||
const greeting = "Hello! My name is " + firstName + " " + lastName + " and I am " + (thisYear - birthYear) + " years old.";
|
||||
|
||||
console.log(greeting);
|
||||
|
||||
/*
|
||||
|
||||
===== Step 2: =====
|
||||
Once you understand the code snippet above, delete it. Then, using the following instructions, recreate the snippet on your own under "Your code goes here".
|
||||
|
||||
---------------------------------------------------------------
|
||||
|
||||
1. Create 4 variables: firstName, lastName, thisYear, and birthYear
|
||||
|
||||
2. Create a 5th variable, greeting, that is constructed from the previous 4
|
||||
(it should contain a greeting with the person's full name and their age)
|
||||
|
||||
3. Print greeting with console.log
|
||||
|
||||
4. Press 'Run' to ensure your code works
|
||||
|
||||
---------------------------------------------------------------
|
||||
|
||||
===== NOTE =====
|
||||
In order to make the tests pass you will need to use these exact values. The wording also needs to be an exact match. If the tests fail, check spacing, capitalization, and punctuation:
|
||||
|
||||
birth year = 1948
|
||||
this year = 1965
|
||||
first name = Carlos
|
||||
last name = Stevenson
|
||||
|
||||
The greeting should say: "Hello! My name is Carlos Stevenson and I am 17 years old."
|
||||
|
||||
*/
|
||||
|
||||
//===== Your code goes here =================
|
||||
|
||||
|
||||
/*
|
||||
|
||||
===== Step 3: =====
|
||||
Now that you have the code working again, let's go back over it and, using the instructions below, edit it to make it easier to read.
|
||||
|
||||
---------------------------------------------------------------
|
||||
|
||||
1. Go to "Testing your code" below
|
||||
|
||||
2. Comment out the lines under "Test Step 2"
|
||||
|
||||
3. Uncomment the lines under "Test Step 3" (Notice the difference between them)
|
||||
|
||||
4. Go back to your code and create 2 new variables: "fullName" and "age"
|
||||
|
||||
Do NOT simply type the full name and age into the new variables. Set them using the pre-existing variables, with the calculations that are currently inside of greeting.
|
||||
|
||||
5. Edit the greeting string to use fullName and age instead of the other 4 variables. (the greeting should then look something like: "Hello! My name is " + fullName)
|
||||
|
||||
6. Press 'Run' to ensure your code still works (output should be unchanged)
|
||||
|
||||
---------------------------------------------------------------
|
||||
|
||||
===== Testing your code =====
|
||||
- Do NOT edit this section until told to do so.
|
||||
|
||||
- Make sure one and only one of these test steps are commented out at a time
|
||||
|
||||
*/
|
||||
|
||||
// Test Step 2:
|
||||
|
||||
module.exports = {
|
||||
testGroup: "a",
|
||||
greeting,
|
||||
birthYear,
|
||||
thisYear,
|
||||
firstName,
|
||||
lastName
|
||||
}
|
||||
|
||||
|
||||
// Test Step 3: (Don't forget to comment out lines under Test Step 2)
|
||||
|
||||
// module.exports = {
|
||||
// testGroup: "b",
|
||||
// greeting,
|
||||
// birthYear,
|
||||
// thisYear,
|
||||
// firstName,
|
||||
// lastName,
|
||||
// fullName,
|
||||
// age
|
||||
// }
|
|
@ -0,0 +1,84 @@
|
|||
|
||||
|
||||
const values = require("./follow");
|
||||
let errored = false;
|
||||
|
||||
console.log("\n---------------------------------\n\n")
|
||||
|
||||
if(values.testGroup === "a") {
|
||||
if(values.birthYear !== 1948) {
|
||||
console.error(`birthYear is incorrect, it's currently: "${values.birthYear}"`);
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if(values.thisYear !== 1965) {
|
||||
console.error(`thisYear is incorrect, it's currently: "${values.thisYear}"`);
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if(values.firstName !== "Carlos") {
|
||||
console.error(`firstName is incorrect, it's currently: "${values.firstName}"`);
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if(values.lastName !== "Stevenson") {
|
||||
console.error(`lastName is incorrect, it's currently: "${values.lastName}"`);
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if(values.greeting !== "Hello! My name is Carlos Stevenson and I am 17 years old.") {
|
||||
console.error(`greeting is incorrect, it's currently: "${values.greeting}"`);
|
||||
errored = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(values.testGroup === "b") {
|
||||
if(values.birthYear !== 1948) {
|
||||
console.error(`birthYear is incorrect, it's currently: "${values.birthYear}"`);
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if(values.thisYear !== 1965) {
|
||||
console.error(`thisYear is incorrect, it's currently: "${values.thisYear}"`);
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if(values.firstName !== "Carlos") {
|
||||
console.error(`firstName is incorrect, it's currently: "${values.firstName}"`);
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if(values.lastName !== "Stevenson") {
|
||||
console.error(`lastName is incorrect, it's currently: "${values.lastName}"`);
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if(values.age !== 17) {
|
||||
console.error(`age is incorrect, it's currently: "${values.age}"`);
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if(values.fullName !== "Carlos Stevenson") {
|
||||
console.error(`fullName is incorrect, it's currently: "${values.fullName}"`);
|
||||
errored = true;
|
||||
}
|
||||
|
||||
if(values.greeting !== "Hello! My name is Carlos Stevenson and I am 17 years old.") {
|
||||
console.error(`greeting is incorrect, it's currently: "${values.greeting}"`);
|
||||
errored = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!errored && values.testGroup === "a") {
|
||||
console.log("Congrats! Move onto the next step!");
|
||||
} else if (errored && values.testGroup === "a") {
|
||||
console.log("Try again")
|
||||
}
|
||||
|
||||
if(!errored && values.testGroup === "b") {
|
||||
console.log("Congrats! Move onto the next lesson!");
|
||||
} else if (errored) {
|
||||
console.log("Try again")
|
||||
}
|
||||
|
||||
console.log("\n---------------------------------\n\n")
|
Loading…
Reference in New Issue