diff --git a/.learn/resets/01-Hello_World/app.js b/.learn/resets/01-Hello_World/app.js new file mode 100644 index 00000000..575cab67 --- /dev/null +++ b/.learn/resets/01-Hello_World/app.js @@ -0,0 +1,2 @@ +//your code below +console.log("hello world") diff --git a/.learn/resets/02-Print_variables_in_the_console/app.js b/.learn/resets/02-Print_variables_in_the_console/app.js new file mode 100644 index 00000000..4d6f4093 --- /dev/null +++ b/.learn/resets/02-Print_variables_in_the_console/app.js @@ -0,0 +1,4 @@ +let mySuperVariable = 'hello'; +console.log(mySuperVariable); + +// your code below diff --git a/.learn/resets/03-Multiply_two_values/app.js b/.learn/resets/03-Multiply_two_values/app.js new file mode 100644 index 00000000..de14e4e5 --- /dev/null +++ b/.learn/resets/03-Multiply_two_values/app.js @@ -0,0 +1 @@ +// Your code below: \ No newline at end of file diff --git a/.learn/resets/04-User_inputed_variables/app.js b/.learn/resets/04-User_inputed_variables/app.js new file mode 100644 index 00000000..64e98ae0 --- /dev/null +++ b/.learn/resets/04-User_inputed_variables/app.js @@ -0,0 +1,3 @@ +let age = prompt('What is your age?'); + +// Your code below: diff --git a/.learn/resets/05-Constants/app.js b/.learn/resets/05-Constants/app.js new file mode 100644 index 00000000..407c5085 --- /dev/null +++ b/.learn/resets/05-Constants/app.js @@ -0,0 +1,5 @@ +const VERSION = '0.1'; + +VERSION = '0.9'; + +console.log(VERSION); \ No newline at end of file diff --git a/.learn/resets/06-String_concatenation/app.js b/.learn/resets/06-String_concatenation/app.js new file mode 100644 index 00000000..7913ca21 --- /dev/null +++ b/.learn/resets/06-String_concatenation/app.js @@ -0,0 +1,7 @@ +//Set the values here +let myVar1 = ''; +let myVar2 = ''; + +//Don't change any code below +let theNewString = myVar1+' '+myVar2; +console.log(theNewString); \ No newline at end of file diff --git a/.learn/resets/07-Create_a_basic_HTML/app.js b/.learn/resets/07-Create_a_basic_HTML/app.js new file mode 100644 index 00000000..901e8f77 --- /dev/null +++ b/.learn/resets/07-Create_a_basic_HTML/app.js @@ -0,0 +1,13 @@ +const a = ''; +const b = ''; +const c = ''; +const d = ''; +const e = ''; +const f = ''; +const g = ''; +const h = '<body>'; + +//Modify this variable +let htmlDocument = 'e+c+g+h+d+a+f+b'; + +console.log(htmlDocument); \ No newline at end of file diff --git a/.learn/resets/08-Calling_your_first_function/app.js b/.learn/resets/08-Calling_your_first_function/app.js new file mode 100644 index 00000000..0fa5a6e9 --- /dev/null +++ b/.learn/resets/08-Calling_your_first_function/app.js @@ -0,0 +1,7 @@ +function isOdd(myNumber) +{ + return !(myNumber % 2 == 0); +} + +// Your code below: +isOdd() \ No newline at end of file diff --git a/.learn/resets/09-Creating_your_first_function/app.js b/.learn/resets/09-Creating_your_first_function/app.js new file mode 100644 index 00000000..feb681a4 --- /dev/null +++ b/.learn/resets/09-Creating_your_first_function/app.js @@ -0,0 +1,7 @@ +function addNumbers(a,b){ + // This is the function's body. Write your code here. + +} + +//Do not change the code below +console.log(addNumbers(3,4)); diff --git a/.learn/resets/10-Create_a_new_function/app.js b/.learn/resets/10-Create_a_new_function/app.js new file mode 100644 index 00000000..1aebdb53 --- /dev/null +++ b/.learn/resets/10-Create_a_new_function/app.js @@ -0,0 +1,7 @@ +function shortIntroduction() { + // Complete this function's body and arguments + +} + +// Fill the gaps with your data in the correct order +console.log(shortIntroduction(" ", " ", " ")) \ No newline at end of file diff --git a/.learn/resets/11-Your_first_if/app.js b/.learn/resets/11-Your_first_if/app.js new file mode 100644 index 00000000..217b619e --- /dev/null +++ b/.learn/resets/11-Your_first_if/app.js @@ -0,0 +1,3 @@ +let total = prompt('How many km are left to go?'); + +// Your code below: diff --git a/.learn/resets/12-How_much_the_wedding_costs/app.js b/.learn/resets/12-How_much_the_wedding_costs/app.js new file mode 100644 index 00000000..d769ef63 --- /dev/null +++ b/.learn/resets/12-How_much_the_wedding_costs/app.js @@ -0,0 +1,12 @@ +let guests = prompt('How many people are coming to your wedding?'); + +function getPrice(guests){ + let cost = 0; + // Your code here + + + return cost; +} + +let price = getPrice(guests); +console.log('Your wedding will cost '+price+' dollars'); diff --git a/.learn/resets/13-Your_first_switch/app.js b/.learn/resets/13-Your_first_switch/app.js new file mode 100644 index 00000000..2bc6601b --- /dev/null +++ b/.learn/resets/13-Your_first_switch/app.js @@ -0,0 +1,17 @@ +function getColor(selection) +{ + switch(selection){ + // Add more options here + default: + return false; //returns false because the user picked an unavailable color + break; + } +} + +let colorname = prompt('What color do you want?').trim(); +let isAvailable = getColor(colorname); + +if(isAvailable) + console.log('Good news! That color is available'); +else + console.log('We are sorry, that color is not available'); diff --git a/.learn/resets/14-Random_numbers/app.js b/.learn/resets/14-Random_numbers/app.js new file mode 100644 index 00000000..73ab6d92 --- /dev/null +++ b/.learn/resets/14-Random_numbers/app.js @@ -0,0 +1,8 @@ +function getRandomInt() +{ + let randomNumber = Math.random(); + return randomNumber; +} + + +console.log(getRandomInt()); diff --git a/.learn/resets/15-Rand_from_one_to_six/app.js b/.learn/resets/15-Rand_from_one_to_six/app.js new file mode 100644 index 00000000..a5f2d3a6 --- /dev/null +++ b/.learn/resets/15-Rand_from_one_to_six/app.js @@ -0,0 +1,6 @@ +function getRandomInt() +{ + let randomNumber = Math.random(); + return randomNumber; +} +console.log(getRandomInt()); \ No newline at end of file diff --git a/.learn/resets/16-Your_first_loop/app.js b/.learn/resets/16-Your_first_loop/app.js new file mode 100644 index 00000000..96256cf1 --- /dev/null +++ b/.learn/resets/16-Your_first_loop/app.js @@ -0,0 +1,3 @@ +for (let i = 0; i < 100; i++) { + console.log(i) +} diff --git a/.learn/resets/17-Create_a_for_loop/app.js b/.learn/resets/17-Create_a_for_loop/app.js new file mode 100644 index 00000000..523830fd --- /dev/null +++ b/.learn/resets/17-Create_a_for_loop/app.js @@ -0,0 +1,4 @@ +// Declare and write your function here: + + +standardsMaker(); \ No newline at end of file diff --git a/.learn/resets/18-While_loop/app.js b/.learn/resets/18-While_loop/app.js new file mode 100644 index 00000000..01fd584b --- /dev/null +++ b/.learn/resets/18-While_loop/app.js @@ -0,0 +1,12 @@ +//fix this function: +function startCounting() { + let counter = 100; + while (counter <= 100) { + counter--; + console.log(counter); + } + + return counter; +} + +startCounting(); \ No newline at end of file diff --git a/.learn/resets/19-Random_colors_loop/app.js b/.learn/resets/19-Random_colors_loop/app.js new file mode 100644 index 00000000..f5113a15 --- /dev/null +++ b/.learn/resets/19-Random_colors_loop/app.js @@ -0,0 +1,26 @@ +function getColor(colorNumber = 0) { + //make sure the parameter is a number and not a string by converting the value to int: + colorNumber = parseInt(colorNumber); + switch (colorNumber) { + case 1: return "red"; + + case 2: return "yellow"; + + case 3: return "blue"; + + case 4: return "green"; + + default: return "black"; + + } +} + +function getAllStudentColors() { + + //your loop here + let exampleColor = getColor(1); +} + +//call the function below with the number of students in the class and print on the console +getAllStudentColors(); + diff --git a/.learn/resets/20-Looping_with_FizzBuzz/app.js b/.learn/resets/20-Looping_with_FizzBuzz/app.js new file mode 100644 index 00000000..2870ef1e --- /dev/null +++ b/.learn/resets/20-Looping_with_FizzBuzz/app.js @@ -0,0 +1,5 @@ +function fizzBuzz() { + // Your code here +} + +fizzBuzz(); \ No newline at end of file diff --git a/.learn/resets/21-Russian_Roulette/app.js b/.learn/resets/21-Russian_Roulette/app.js new file mode 100644 index 00000000..b775e5ff --- /dev/null +++ b/.learn/resets/21-Russian_Roulette/app.js @@ -0,0 +1,16 @@ +// firePosition will be the position in which the gun will fire. +let firePosition = 1; + +// The output of spinChamber will be a number and it can be passed as a parameter to the fireGun function. +const spinChamber = () => { + let chamberPosition = Math.floor((Math.random() * 6) + 1); + return chamberPosition; +}; + +// Remove the // below and complete the commented lines +const fireGun = (bulletPosition) => { + // if (... === firePosition) return ("You're dead!"); + // else return ("Keep playing!"); +}; + +console.log(fireGun(spinChamber())); diff --git a/.learn/resets/22-The_Beatles/app.js b/.learn/resets/22-The_Beatles/app.js new file mode 100644 index 00000000..1111c793 --- /dev/null +++ b/.learn/resets/22-The_Beatles/app.js @@ -0,0 +1,5 @@ + + +//Your code above ^^^ + +console.log(sing()); \ No newline at end of file diff --git a/.learn/resets/23-Bottles_of_milk/app.js b/.learn/resets/23-Bottles_of_milk/app.js new file mode 100644 index 00000000..f37016c1 --- /dev/null +++ b/.learn/resets/23-Bottles_of_milk/app.js @@ -0,0 +1 @@ +// Your code here: diff --git a/.learn/resets/24-Javascript_Objects/app.js b/.learn/resets/24-Javascript_Objects/app.js new file mode 100644 index 00000000..fa1e623a --- /dev/null +++ b/.learn/resets/24-Javascript_Objects/app.js @@ -0,0 +1,38 @@ +var person = { + name: "John", //String + lastName: "Doe", + age: 35, //Number + gender: "male", + luckyNumbers: [7, 11, 13, 17], //Array + significantOther: person2 //Object, yes, the same variable/object defined after +}; + +var person2 = { + name: "Jane", + lastName: "Doe", + age: 38, + gender: "female", + luckyNumbers: [2, 4, 6, 8], + significantOther: person +}; + +var family = { + lastName: "Doe", + members: [person, person2] //Array of objects, don't forget to add Jimmy +}; + + +function addAllFamilyLuckyNumbers(anArray){ + let sumOfAllLuckyNumbers = 0; //sumOfAllLuckyNumbers is a number, the sum of all lucky numbers. + + //To-Do: loop and add; consider nested loops + //Hint: use the anArray variable to get all of the lucky numbers + + return sumOfAllLuckyNumbers; +} + +//Enter all your code here: + + +//Do not make changes below: +console.log(addAllFamilyLuckyNumbers(family.members)); diff --git a/exercises/01-Hello_World/app.js b/exercises/01-Hello_World/app.js index 2290d4e6..1b63d96e 100644 --- a/exercises/01-Hello_World/app.js +++ b/exercises/01-Hello_World/app.js @@ -1 +1,2 @@ //your code below +console.log("Hello World"); diff --git a/exercises/02-Print_variables_in_the_console/app.js b/exercises/02-Print_variables_in_the_console/app.js index 4d6f4093..1acda939 100644 --- a/exercises/02-Print_variables_in_the_console/app.js +++ b/exercises/02-Print_variables_in_the_console/app.js @@ -2,3 +2,5 @@ let mySuperVariable = 'hello'; console.log(mySuperVariable); // your code below +let color = "red"; +console.log(color); \ No newline at end of file diff --git a/exercises/03-Multiply_two_values/app.js b/exercises/03-Multiply_two_values/app.js index de14e4e5..8596b279 100644 --- a/exercises/03-Multiply_two_values/app.js +++ b/exercises/03-Multiply_two_values/app.js @@ -1 +1,4 @@ -// Your code below: \ No newline at end of file +// Your code below: +let variablesAreCool = 2345 * 7323; + +console.log(variablesAreCool); diff --git a/exercises/04-User_inputed_variables/app.js b/exercises/04-User_inputed_variables/app.js index 64e98ae0..8705c786 100644 --- a/exercises/04-User_inputed_variables/app.js +++ b/exercises/04-User_inputed_variables/app.js @@ -1,3 +1,7 @@ let age = prompt('What is your age?'); // Your code below: +age = parseInt(age); +age = age + 10; + +console.log(age); \ No newline at end of file diff --git a/exercises/05-Constants/app.js b/exercises/05-Constants/app.js index 407c5085..c4e13f0a 100644 --- a/exercises/05-Constants/app.js +++ b/exercises/05-Constants/app.js @@ -1,5 +1,5 @@ -const VERSION = '0.1'; +const VERSION = '0.9'; + -VERSION = '0.9'; console.log(VERSION); \ No newline at end of file diff --git a/exercises/06-String_concatenation/app.js b/exercises/06-String_concatenation/app.js index 7913ca21..80dd9155 100644 --- a/exercises/06-String_concatenation/app.js +++ b/exercises/06-String_concatenation/app.js @@ -1,6 +1,6 @@ //Set the values here -let myVar1 = ''; -let myVar2 = ''; +let myVar1 = 'Hello'; +let myVar2 = 'World'; //Don't change any code below let theNewString = myVar1+' '+myVar2; diff --git a/exercises/07-Create_a_basic_HTML/app.js b/exercises/07-Create_a_basic_HTML/app.js index 901e8f77..52259f78 100644 --- a/exercises/07-Create_a_basic_HTML/app.js +++ b/exercises/07-Create_a_basic_HTML/app.js @@ -8,6 +8,6 @@ const g = '<title>'; const h = '<body>'; //Modify this variable -let htmlDocument = 'e+c+g+h+d+a+f+b'; +let htmlDocument = e+c+g+a+f+h+d+b; console.log(htmlDocument); \ No newline at end of file diff --git a/exercises/08-Calling_your_first_function/app.js b/exercises/08-Calling_your_first_function/app.js index 0fa5a6e9..b251d668 100644 --- a/exercises/08-Calling_your_first_function/app.js +++ b/exercises/08-Calling_your_first_function/app.js @@ -4,4 +4,4 @@ function isOdd(myNumber) } // Your code below: -isOdd() \ No newline at end of file +console.log(isOdd(45345)) diff --git a/exercises/09-Creating_your_first_function/app.js b/exercises/09-Creating_your_first_function/app.js index feb681a4..fd5fc0de 100644 --- a/exercises/09-Creating_your_first_function/app.js +++ b/exercises/09-Creating_your_first_function/app.js @@ -1,6 +1,6 @@ function addNumbers(a,b){ // This is the function's body. Write your code here. - + return a + b; } //Do not change the code below diff --git a/exercises/10-Create_a_new_function/app.js b/exercises/10-Create_a_new_function/app.js index 1aebdb53..a3fd5fb4 100644 --- a/exercises/10-Create_a_new_function/app.js +++ b/exercises/10-Create_a_new_function/app.js @@ -1,7 +1,7 @@ -function shortIntroduction() { +function shortIntroduction(name, profession, age) { // Complete this function's body and arguments - + return "Hello! my name is " + name +", my profession is " + profession + ". I am " + age + " years old." } // Fill the gaps with your data in the correct order -console.log(shortIntroduction(" ", " ", " ")) \ No newline at end of file +console.log(shortIntroduction("Ayelen", "Abogada", "33")) \ No newline at end of file diff --git a/exercises/11-Your_first_if/app.js b/exercises/11-Your_first_if/app.js index 217b619e..6e3254d9 100644 --- a/exercises/11-Your_first_if/app.js +++ b/exercises/11-Your_first_if/app.js @@ -1,3 +1,11 @@ let total = prompt('How many km are left to go?'); // Your code below: + +if (total <= 50) { + console.log("I'm parking. I'll see you right now"); +} else if (total <= 100) { + console.log("We'll be there in 5 minutes"); +} else { + console.log("We still have a bit of driving left to go"); +} \ No newline at end of file diff --git a/exercises/12-How_much_the_wedding_costs/app.js b/exercises/12-How_much_the_wedding_costs/app.js index d769ef63..5a6f9c06 100644 --- a/exercises/12-How_much_the_wedding_costs/app.js +++ b/exercises/12-How_much_the_wedding_costs/app.js @@ -3,9 +3,27 @@ let guests = prompt('How many people are coming to your wedding?'); function getPrice(guests){ let cost = 0; // Your code here - + + let people = Number(guests); + + if (people > 200) { + cost = 20000 + } + + else if (people <= 200 && people > 100) { + cost = 15000 + } + + else if (people <= 100 && people > 50) { + cost = 10000 + } + + else if (people <= 50) { + cost = 4000 + } return cost; + } let price = getPrice(guests); diff --git a/exercises/12-How_much_the_wedding_costs/tests.js b/exercises/12-How_much_the_wedding_costs/tests.js index 22ec2ecb..1cdbc850 100644 --- a/exercises/12-How_much_the_wedding_costs/tests.js +++ b/exercises/12-How_much_the_wedding_costs/tests.js @@ -4,55 +4,55 @@ let fs = require('fs'); let path = require('path'); it("Create an if statement", function () { - const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); + const app_content = fs.readFileSync(path.resolve(__dirname, './temporal.js'), 'utf8'); expect(app_content).toMatch(/if\s*/); }); it('The function getPrice must exist', function () { - const app = rewire('./app.js'); + const app = rewire('./temporal.js'); const getPrice = app.__get__('getPrice') expect(getPrice).toBeTruthy(); }); it('When tested for 50 it should return 4000', function () { - const app = rewire('./app.js'); + const app = rewire('./temporal.js'); const getPrice = app.__get__('getPrice') expect(getPrice(50)).toBe(4000); }); it('When tested for 51 it should return 10000', function () { - const app = rewire('./app.js'); + const app = rewire('./temporal.js'); const getPrice = app.__get__('getPrice') expect(getPrice(51)).toBe(10000); }); it('When tested for 100 it should return 10000', function () { - const app = rewire('./app.js'); + const app = rewire('./temporal.js'); const getPrice = app.__get__('getPrice') expect(getPrice(100)).toBe(10000); }); it('When tested for 101 it should return 15000', function () { - const app = rewire('./app.js'); + const app = rewire('./temporal.js'); const getPrice = app.__get__('getPrice') expect(getPrice(101)).toBe(15000); }); it('When tested for 200 it should return 15000', function () { - const app = rewire('./app.js'); + const app = rewire('./temporal.js'); const getPrice = app.__get__('getPrice') expect(getPrice(200)).toBe(15000); }); it('When tested for 201 it should return 20000', function () { - const app = rewire('./app.js'); + const app = rewire('./temporal.js'); const getPrice = app.__get__('getPrice') expect(getPrice(201)).toBe(20000); }); it('When tested for 400 it should return 20000', function () { - const app = rewire('./app.js'); + const app = rewire('./temporal.js'); const getPrice = app.__get__('getPrice') expect(getPrice(400)).toBe(20000); }); diff --git a/exercises/13-Your_first_switch/app.js b/exercises/13-Your_first_switch/app.js index 2bc6601b..11be23d8 100644 --- a/exercises/13-Your_first_switch/app.js +++ b/exercises/13-Your_first_switch/app.js @@ -4,11 +4,20 @@ function getColor(selection) // Add more options here default: return false; //returns false because the user picked an unavailable color - break; + break; + case "red": + return true; + break; + case "green": + return true; + break; + case "blue": + return true; + break; } } -let colorname = prompt('What color do you want?').trim(); +let colorname = prompt('What color do you want?').trim().toLowerCase; let isAvailable = getColor(colorname); if(isAvailable) diff --git a/exercises/13-Your_first_switch/tests.js b/exercises/13-Your_first_switch/tests.js index deade9a0..fa02c37d 100644 --- a/exercises/13-Your_first_switch/tests.js +++ b/exercises/13-Your_first_switch/tests.js @@ -1,6 +1,6 @@ const rewire = require('rewire'); -const file = rewire("./app.js"); +const file = rewire("./temporal.js"); const getColor = file.__get__('getColor'); test('function getColor should exist', function () { expect(getColor).toBeTruthy(); diff --git a/exercises/14-Random_numbers/app.js b/exercises/14-Random_numbers/app.js index 73ab6d92..55b6af4b 100644 --- a/exercises/14-Random_numbers/app.js +++ b/exercises/14-Random_numbers/app.js @@ -1,6 +1,6 @@ function getRandomInt() { - let randomNumber = Math.random(); + let randomNumber = Math.floor((Math.random() * 10) + 1); return randomNumber; } diff --git a/exercises/15-Rand_from_one_to_six/app.js b/exercises/15-Rand_from_one_to_six/app.js index a5f2d3a6..a714c7cd 100644 --- a/exercises/15-Rand_from_one_to_six/app.js +++ b/exercises/15-Rand_from_one_to_six/app.js @@ -1,6 +1,6 @@ function getRandomInt() { - let randomNumber = Math.random(); + let randomNumber = Math.floor((Math.random() * 6) +1); return randomNumber; } console.log(getRandomInt()); \ No newline at end of file diff --git a/exercises/16-Your_first_loop/app.js b/exercises/16-Your_first_loop/app.js index 96256cf1..b731b45e 100644 --- a/exercises/16-Your_first_loop/app.js +++ b/exercises/16-Your_first_loop/app.js @@ -1,3 +1,3 @@ -for (let i = 0; i < 100; i++) { +for (let i = 0; i <= 100; i++) { console.log(i) } diff --git a/exercises/17-Create_a_for_loop/app.js b/exercises/17-Create_a_for_loop/app.js index 523830fd..9a00f4ea 100644 --- a/exercises/17-Create_a_for_loop/app.js +++ b/exercises/17-Create_a_for_loop/app.js @@ -1,4 +1,8 @@ // Declare and write your function here: - +function standardsMaker() { + for (let i = 0; i < 300; i++) { + console.log("I will write questions if I'm stuck"); + } +} standardsMaker(); \ No newline at end of file diff --git a/exercises/18-While_loop/app.js b/exercises/18-While_loop/app.js index 01fd584b..03618403 100644 --- a/exercises/18-While_loop/app.js +++ b/exercises/18-While_loop/app.js @@ -1,12 +1,11 @@ //fix this function: function startCounting() { let counter = 100; - while (counter <= 100) { - counter--; + while (counter >= 0) { console.log(counter); + counter--; } - - return counter; + return 0; } startCounting(); \ No newline at end of file diff --git a/exercises/19-Random_colors_loop/app.js b/exercises/19-Random_colors_loop/app.js index f5113a15..c1b18baa 100644 --- a/exercises/19-Random_colors_loop/app.js +++ b/exercises/19-Random_colors_loop/app.js @@ -15,12 +15,14 @@ function getColor(colorNumber = 0) { } } -function getAllStudentColors() { - - //your loop here - let exampleColor = getColor(1); +function getAllStudentColors(numberOfStudents) { + for (let i = 0; i < numberOfStudents; i++) { + let randomNum = Math.floor(Math.random() * 4) + 1; // Número entre 1 y 4 + let color = getColor(randomNum); // Obtener el color según el número + console.log(color); // Imprimir el color + } } //call the function below with the number of students in the class and print on the console -getAllStudentColors(); +getAllStudentColors(10); diff --git a/exercises/20-Looping_with_FizzBuzz/app.js b/exercises/20-Looping_with_FizzBuzz/app.js index 2870ef1e..bc42f6e7 100644 --- a/exercises/20-Looping_with_FizzBuzz/app.js +++ b/exercises/20-Looping_with_FizzBuzz/app.js @@ -1,5 +1,15 @@ -function fizzBuzz() { - // Your code here +function fizzBuzz() { + for (let i = 1; i <= 100; i++) { + + if (i % 3 === 0 && i % 5 === 0) { + console.log("FizzBuzz"); + } else if (i % 3 === 0) { + console.log("Fizz"); + } else if (i % 5 === 0) { + console.log("Buzz"); + } else { + console.log(i); + } + } } - fizzBuzz(); \ No newline at end of file diff --git a/exercises/21-Russian_Roulette/app.js b/exercises/21-Russian_Roulette/app.js index b775e5ff..aaaadec4 100644 --- a/exercises/21-Russian_Roulette/app.js +++ b/exercises/21-Russian_Roulette/app.js @@ -9,8 +9,11 @@ const spinChamber = () => { // Remove the // below and complete the commented lines const fireGun = (bulletPosition) => { - // if (... === firePosition) return ("You're dead!"); - // else return ("Keep playing!"); + if (bulletPosition === firePosition) { + return "You're dead!"; + } else { + return "Keep playing!"; + } }; console.log(fireGun(spinChamber())); diff --git a/exercises/22-The_Beatles/app.js b/exercises/22-The_Beatles/app.js index 1111c793..d958ac8a 100644 --- a/exercises/22-The_Beatles/app.js +++ b/exercises/22-The_Beatles/app.js @@ -1,5 +1,19 @@ +function sing (){ + let lyrics = ""; + + for (let i = 1; i <= 8; i++){ + lyrics += "let it be, "; + if (i === 4){ + lyrics += "there will be an answer, " + } + } + + lyrics += "let it be, whisper words of wisdom, let it be"; + + return lyrics; +} //Your code above ^^^ console.log(sing()); \ No newline at end of file diff --git a/exercises/23-Bottles_of_milk/app.js b/exercises/23-Bottles_of_milk/app.js index f37016c1..a816758f 100644 --- a/exercises/23-Bottles_of_milk/app.js +++ b/exercises/23-Bottles_of_milk/app.js @@ -1 +1,17 @@ // Your code here: +function milk() { + for (let i = 99; i >= 1; i--) { + if (i > 2) { + console.log(`${i} bottles of milk on the wall, ${i} bottles of milk. Take one down and pass it around, ${i - 1} bottles of milk on the wall.`); + } else if (i === 2) { + console.log(`${i} bottles of milk on the wall, ${i} bottles of milk. Take one down and pass it around, 1 bottle of milk on the wall.`); + } else if (i === 1) { + console.log(`${i} bottle of milk on the wall, ${i} bottle of milk. Take one down and pass it around, no more bottles of milk on the wall.`); + } + } + + console.log("No more bottles of milk on the wall, no more bottles of milk. Go to the store and buy some more, 99 bottles of milk on the wall."); +} +//Your code above ^^^ + +milk(); \ No newline at end of file diff --git a/exercises/24-Javascript_Objects/app.js b/exercises/24-Javascript_Objects/app.js index fa1e623a..72af4dea 100644 --- a/exercises/24-Javascript_Objects/app.js +++ b/exercises/24-Javascript_Objects/app.js @@ -28,11 +28,29 @@ function addAllFamilyLuckyNumbers(anArray){ //To-Do: loop and add; consider nested loops //Hint: use the anArray variable to get all of the lucky numbers + for (let i = 0; i < anArray.length; i++) { + let luckyNumbers = anArray[i].luckyNumbers; + for (let j = 0; j < luckyNumbers.length; j++) { + sumOfAllLuckyNumbers += luckyNumbers[j]; + } + } + return sumOfAllLuckyNumbers; } //Enter all your code here: +family.members[0].luckyNumbers[3] = 33; +var jimmy = { + name: "Jimmy", + lastName: "Doe", + age: 13, + gender: "male", + luckyNumbers: [1, 2, 3,4], + significantOther: null + }; + + family.members.push(jimmy); //Do not make changes below: console.log(addAllFamilyLuckyNumbers(family.members));