Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Katherine Souza Control_Flow_Homework 11.16.22 #7

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
90 changes: 63 additions & 27 deletions lib/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -35,11 +35,14 @@ function 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"

Expand All @@ -50,11 +53,13 @@ function 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"

Expand All @@ -65,11 +70,13 @@ function 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"

Expand All @@ -79,7 +86,9 @@ function 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!
Expand All @@ -95,7 +104,10 @@ 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!
Expand All @@ -114,11 +126,14 @@ 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}. High five!`);
};
};

// COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER!
// prompt7()
prompt7()

// 🌟 MAKE A COMMIT: "Complete prompt 7"

Expand All @@ -138,14 +153,19 @@ function prompt7() {
var someNumber;

function prompt8() {
// print someNumber to the console in your function so you can see its value
someNumber = Math.floor(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"

Expand All @@ -163,7 +183,8 @@ function 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!
Expand All @@ -178,9 +199,10 @@ function prompt9() {
* then print the array.
*/
function prompt10() {
const myArray = [];
// YOUR CODE HERE

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;
Expand Down Expand Up @@ -230,10 +252,13 @@ let nums = [

function prompt11() {
let median;
// YOUR CODE HERE

console.log(median);
nums.sort();
let med = Math.floor(nums.length / 2);
median = nums[med];
console.log(median);
}


// COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER!
// prompt11();

Expand All @@ -253,7 +278,10 @@ 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!
Expand All @@ -274,11 +302,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"

Expand Down
1 change: 1 addition & 0 deletions lib/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<script src="./challenge.js" defer></script>
<title>Control Flow Practice</title>
</head>
<body>
Expand Down