From a516c8819948ce52d0a072b60c0150be76bf43f7 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 12:52:17 -0500 Subject: [PATCH 01/17] Complete prompt 1 --- lib/challenge.js | 2 +- lib/index.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/challenge.js b/lib/challenge.js index 21f3ae03..db7cf8f9 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -24,7 +24,7 @@ function prompt1() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt1() +prompt1() // 🌟 MAKE A COMMIT: "Complete prompt 1" diff --git a/lib/index.html b/lib/index.html index f6f038aa..34139a7d 100644 --- a/lib/index.html +++ b/lib/index.html @@ -3,6 +3,7 @@ + Control Flow Practice From 023d191b149275fa9f6640feaf3d248bc03ce827 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 13:11:45 -0500 Subject: [PATCH 02/17] Complete prompt 2 --- lib/challenge.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index db7cf8f9..c52984ec 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -24,7 +24,7 @@ function prompt1() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -prompt1() +//prompt1() // 🌟 MAKE A COMMIT: "Complete prompt 1" @@ -35,11 +35,14 @@ prompt1() */ function prompt2() { - // YOUR CODE HERE + for (let i = 1; i < 100; i++) { + if (!(i % 2)) + console.log(i) + } } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt2(); +prompt2(); // 🌟 MAKE A COMMIT: "Complete prompt 2" From 29d492fc648098ba409eacd347a0a0564b03d333 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 13:14:32 -0500 Subject: [PATCH 03/17] Complete prompt 3 --- lib/challenge.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index c52984ec..71b29ead 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -37,12 +37,12 @@ function prompt1() { function prompt2() { for (let i = 1; i < 100; i++) { if (!(i % 2)) - console.log(i) + console.log(i); } } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -prompt2(); +//prompt2(); // 🌟 MAKE A COMMIT: "Complete prompt 2" @@ -53,11 +53,13 @@ prompt2(); */ function prompt3() { - // YOUR CODE HERE + for (let i = -5; i <= 5; i++) { + console.log(i); + } } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt3() +prompt3() // 🌟 MAKE A COMMIT: "Complete prompt 3" From 3782a4f5ef0fcf305a90acfbbbe9bc77a84d8b99 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 13:16:30 -0500 Subject: [PATCH 04/17] Complete prompt 4 --- lib/challenge.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index 71b29ead..61e5eb65 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -59,7 +59,7 @@ function prompt3() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -prompt3() +//prompt3() // 🌟 MAKE A COMMIT: "Complete prompt 3" @@ -70,11 +70,13 @@ prompt3() */ function prompt4() { - // YOUR CODE HERE + for (let i = 10; i >= 0; i--) { + console.log(i); + } } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt4() +prompt4() // 🌟 MAKE A COMMIT: "Complete prompt 4" From ca853c0d891acfc7496ec617962d2d52962010c9 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 13:17:50 -0500 Subject: [PATCH 05/17] Complete prompt 5 --- lib/challenge.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index 61e5eb65..bfb814a6 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -76,7 +76,7 @@ function prompt4() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -prompt4() +//prompt4() // 🌟 MAKE A COMMIT: "Complete prompt 4" @@ -86,11 +86,13 @@ prompt4() * Create a loop that counts down from 5 to -5, printing each number (including 5 and -5). */ function prompt5() { - // YOUR CODE HERE + for (let i = 5; i >= -5; i--) { + console.log(i); + } } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt5() + prompt5() // 🌟 MAKE A COMMIT: "Complete prompt 5" From c343ba5d728ba737bbeb7d5f72e1d3bc9e13c888 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 13:20:00 -0500 Subject: [PATCH 06/17] Complete prompt 6 --- lib/challenge.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index bfb814a6..d13e9a56 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -92,7 +92,7 @@ function prompt5() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! - prompt5() +// prompt5() // 🌟 MAKE A COMMIT: "Complete prompt 5" @@ -104,11 +104,14 @@ function prompt5() { */ function prompt6() { - // YOUR CODE HERE + for (let i = 0; i <= 50; i++) { + if(!(i % 2)) + console.log(i); + } } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt6() + prompt6() // 🌟 MAKE A COMMIT: "Complete prompt 6" From eed456fdc780f7bd066a1e545e2e80cac1def6e8 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 13:29:57 -0500 Subject: [PATCH 07/17] Complte prompt 7 --- lib/challenge.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index d13e9a56..99f8e8e5 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -111,7 +111,7 @@ function prompt6() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! - prompt6() +// prompt6() // 🌟 MAKE A COMMIT: "Complete prompt 6" @@ -126,11 +126,15 @@ function prompt6() { * - I found a 10. High five! */ function prompt7() { - // YOUR CODE HERE + for (let i = 0; i <= 100; i++) { + if(i % 5 == 0) { + console.log(`I found a ${i}. Hight five!`); + } + } } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt7() +prompt7() // 🌟 MAKE A COMMIT: "Complete prompt 7" From dbd773b6269bbe1b321d21631a872e734016bab1 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 14:29:59 -0500 Subject: [PATCH 08/17] Complete prompt 8 --- lib/challenge.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index 99f8e8e5..5413b989 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -134,7 +134,7 @@ function prompt7() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -prompt7() +//prompt7() // 🌟 MAKE A COMMIT: "Complete prompt 7" @@ -154,14 +154,19 @@ prompt7() var someNumber; function prompt8() { - // print someNumber to the console in your function so you can see its value + someNumber = Math.random() * 100 console.log(someNumber); - - // YOUR CODE HERE -} + if (someNumber >= 1 && someNumber <30) { + console.log("That's a small number!") + } else if (someNumber >= 30 && someNumber <60) { + console.log("The number is medium sized.") + } else { + console.log("We got a big one!"); + } + }; // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt8(); +prompt8(); // 🌟 MAKE A COMMIT: "Complete prompt 8" From 83c4b552312fe99c6a19d3d0bc00b0a30cf9c826 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 14:48:28 -0500 Subject: [PATCH 09/17] Complete prompt 9 --- lib/challenge.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index 5413b989..d4daab2d 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -166,7 +166,7 @@ function prompt8() { }; // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -prompt8(); +//prompt8(); // 🌟 MAKE A COMMIT: "Complete prompt 8" @@ -184,11 +184,12 @@ prompt8(); const starWars = ["Han", "C3PO", "R2D2", "Luke", "Leia", "Anakin"]; function prompt9() { - // YOUR CODE HERE + for (let i = 0; i < starWars.length; i++) + console.log(`${[i]}. ${starWars[i]}`); } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt9(); + prompt9(); // 🌟 MAKE A COMMIT: "Complete prompt 9" From 25181fe1e1d532910c4e978c224c57b6529c2340 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 14:51:45 -0500 Subject: [PATCH 10/17] Complete prompt 10 --- lib/challenge.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index d4daab2d..6db88222 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -189,7 +189,7 @@ function prompt9() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! - prompt9(); + //prompt9(); // 🌟 MAKE A COMMIT: "Complete prompt 9" @@ -201,7 +201,8 @@ function prompt9() { */ function prompt10() { const myArray = []; - // YOUR CODE HERE + for (let i = 0; i <= 100; i++) + myArray.push(i) // don't forget to return the array after pushing the numbers into it so you can see it in the browser! // return the array @@ -209,7 +210,7 @@ function prompt10() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// console.log(prompt10()); + console.log(prompt10()); // 🌟 MAKE A COMMIT: "Complete prompt 10" From 9028a18d62251c3e988699117be114ec860eaf8b Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 18:07:34 -0500 Subject: [PATCH 11/17] Semi-completed prompt 11 --- lib/challenge.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index 6db88222..b9b5b837 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -210,7 +210,7 @@ function prompt10() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! - console.log(prompt10()); + //console.log(prompt10()); // 🌟 MAKE A COMMIT: "Complete prompt 10" @@ -252,13 +252,18 @@ let nums = [ ]; function prompt11() { - let median; - // YOUR CODE HERE - - console.log(median); + nums.sort(); + let i = nums.length; + if (i % 2 != 0) { + console.log(nums[i / 2]); + } else { + console.log(nums[Math.floor((i-1) / 2)] + nums[i / 2] /2); + } } + + // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt11(); + prompt11(); // 🌟 MAKE A COMMIT: "Complete prompt 11" From 08cc1620afc07cdd61d4f7409b52d19fa5377340 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 18:15:16 -0500 Subject: [PATCH 12/17] Complete prompt 12 --- lib/challenge.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index b9b5b837..63c6dae7 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -263,7 +263,7 @@ function prompt11() { // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! - prompt11(); +// prompt11(); // 🌟 MAKE A COMMIT: "Complete prompt 11" @@ -281,11 +281,14 @@ function prompt11() { */ function prompt12() { - // YOUR CODE HERE + for (let i = 1; i <= 10; i++) { + for (let j = 11; j <= 20; j++) { + console.log(`i: ${i} / j: ${j}`)} + } } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt12(); +prompt12(); // 🌟 MAKE A COMMIT: "Complete prompt 12" From 9d31dfd3c83fbb61da7e2ad0a83f1bc3263b3e6b Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 16 Nov 2022 18:19:09 -0500 Subject: [PATCH 13/17] Complete prompt 13 --- lib/challenge.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index 63c6dae7..d1f2374d 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -288,7 +288,7 @@ function prompt12() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -prompt12(); +// prompt12(); // 🌟 MAKE A COMMIT: "Complete prompt 12" @@ -305,11 +305,19 @@ let nestedArrays = [ ]; function prompt13() { - // YOUR CODE HERE + console.log(nestedArrays[0][0]); + console.log(nestedArrays[0][1]); + console.log(nestedArrays[0][2]); + console.log(nestedArrays[1][0]); + console.log(nestedArrays[1][1]); + console.log(nestedArrays[1][2]); + console.log(nestedArrays[2][0]); + console.log(nestedArrays[2][1]); + console.log(nestedArrays[2][2]); } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt13(); +prompt13(); // 🌟 MAKE A COMMIT: "Complete prompt 13" From 877909075f8c70d4907f7b9119586187da4ef384 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Thu, 17 Nov 2022 08:49:46 -0500 Subject: [PATCH 14/17] Finally completed prompt 11 --- lib/challenge.js | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index d1f2374d..5db229f4 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -127,14 +127,13 @@ function prompt6() { */ function prompt7() { for (let i = 0; i <= 100; i++) { - if(i % 5 == 0) { + if (i % 5 == 0) console.log(`I found a ${i}. Hight five!`); } } -} // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -//prompt7() +// prompt7() // 🌟 MAKE A COMMIT: "Complete prompt 7" @@ -154,11 +153,11 @@ function prompt7() { var someNumber; function prompt8() { - someNumber = Math.random() * 100 + someNumber = Math.floor(Math.random() * 99) + 1 console.log(someNumber); - if (someNumber >= 1 && someNumber <30) { + if (someNumber >= 1 && someNumber <=30) { console.log("That's a small number!") - } else if (someNumber >= 30 && someNumber <60) { + } else if (someNumber > 30 && someNumber <= 60) { console.log("The number is medium sized.") } else { console.log("We got a big one!"); @@ -189,7 +188,7 @@ function prompt9() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! - //prompt9(); +// prompt9(); // 🌟 MAKE A COMMIT: "Complete prompt 9" @@ -201,7 +200,7 @@ function prompt9() { */ function prompt10() { const myArray = []; - for (let i = 0; i <= 100; i++) + //for (let i > 0, i < 100, i++); myArray.push(i) // don't forget to return the array after pushing the numbers into it so you can see it in the browser! @@ -210,7 +209,7 @@ function prompt10() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! - //console.log(prompt10()); +// console.log(prompt10()); // 🌟 MAKE A COMMIT: "Complete prompt 10" @@ -252,13 +251,11 @@ let nums = [ ]; function prompt11() { + let median; nums.sort(); - let i = nums.length; - if (i % 2 != 0) { - console.log(nums[i / 2]); - } else { - console.log(nums[Math.floor((i-1) / 2)] + nums[i / 2] /2); - } + let med = Math.floor(nums.length / 2); + median = nums[med]; + console.log(median); } @@ -317,7 +314,7 @@ function prompt13() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -prompt13(); +//prompt13(); // 🌟 MAKE A COMMIT: "Complete prompt 13" From e669fd0c9794a06d4d504b88ad66abfc729be105 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Thu, 17 Nov 2022 09:12:35 -0500 Subject: [PATCH 15/17] Re-done prompt 10 --- lib/challenge.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index 5db229f4..42e6ccc6 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -127,7 +127,7 @@ function prompt6() { */ function prompt7() { for (let i = 0; i <= 100; i++) { - if (i % 5 == 0) + if (i % 5 === 0) console.log(`I found a ${i}. Hight five!`); } } @@ -199,17 +199,17 @@ function prompt9() { * then print the array. */ function prompt10() { - const myArray = []; - //for (let i > 0, i < 100, i++); - myArray.push(i) - + let myArray = []; + for (let i = 1; i < 100; i++) + if(i % 2 == 0) + myArray.push(i); // don't forget to return the array after pushing the numbers into it so you can see it in the browser! // return the array return myArray; } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// console.log(prompt10()); + console.log(prompt10()); // 🌟 MAKE A COMMIT: "Complete prompt 10" From 4ce33328ba87acb814534a3b435c901c724121cc Mon Sep 17 00:00:00 2001 From: ksooooza Date: Thu, 17 Nov 2022 09:15:14 -0500 Subject: [PATCH 16/17] Re-done prompt 8 --- lib/challenge.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index 42e6ccc6..591e2a73 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -153,7 +153,7 @@ function prompt7() { var someNumber; function prompt8() { - someNumber = Math.floor(Math.random() * 99) + 1 + someNumber = Math.floor(Math.random() * 100) console.log(someNumber); if (someNumber >= 1 && someNumber <=30) { console.log("That's a small number!") @@ -165,7 +165,7 @@ function prompt8() { }; // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -//prompt8(); +prompt8(); // 🌟 MAKE A COMMIT: "Complete prompt 8" @@ -209,7 +209,7 @@ function prompt10() { } // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! - console.log(prompt10()); +// console.log(prompt10()); // 🌟 MAKE A COMMIT: "Complete prompt 10" From e15a9a5415af9d441fdd668b67b13106c621dd6b Mon Sep 17 00:00:00 2001 From: ksooooza Date: Thu, 17 Nov 2022 09:35:56 -0500 Subject: [PATCH 17/17] Re-done prompt 7 --- lib/challenge.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/challenge.js b/lib/challenge.js index 591e2a73..4a935383 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -127,13 +127,13 @@ function prompt6() { */ function prompt7() { for (let i = 0; i <= 100; i++) { - if (i % 5 === 0) - console.log(`I found a ${i}. Hight five!`); - } - } + if (i % 5 == 0) + console.log(`I found a ${i}. High five!`); + }; + }; // COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER! -// prompt7() +prompt7() // 🌟 MAKE A COMMIT: "Complete prompt 7"