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

Xavier Valtierra -Flow_Control_Deliverable #11

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
81 changes: 68 additions & 13 deletions lib/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function prompt1() {

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

//oooookaaayy
// 🌟 MAKE A COMMIT: "Complete prompt 1"

/*
Expand All @@ -36,11 +36,16 @@ function prompt1() {

function prompt2() {
// YOUR CODE HERE
for(i = 2; i < 100; i++){
if (i% 2 === 0){
console.log(i);
}
}
}

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

// Comment? Cool im commenting.
// 🌟 MAKE A COMMIT: "Complete prompt 2"

/*
Expand All @@ -51,8 +56,10 @@ function prompt2() {

function prompt3() {
// YOUR CODE HERE
for(i = -5; i <= 5; i++){
console.log(i);
}
}

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

Expand All @@ -66,10 +73,13 @@ function prompt3() {

function prompt4() {
// YOUR CODE HERE
for(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 @@ -80,6 +90,12 @@ function prompt4() {
*/
function prompt5() {
// YOUR CODE HERE
let i;
for(i = 5; i >= -5; i--){
console.log(i);
}
if (i = -5)
console.log("Im done!");
}

// COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER!
Expand All @@ -96,6 +112,11 @@ function prompt5() {

function prompt6() {
// YOUR CODE HERE
for(i = 0; i <= 50; i++){
if(i% 2 == 0){
console.log(i);
}
}
}

// COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER!
Expand All @@ -115,6 +136,12 @@ function prompt6() {
*/
function prompt7() {
// YOUR CODE HERE
for(i = 0; i <= 100; i++){
if(i% 5 == 0){
console.log("I found a " + i + " High five!");
//dont know the other method of logging the output without the "+"
}
}
}

// COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER!
Expand All @@ -135,13 +162,22 @@ function prompt7() {
*/

// define someNumber here
var someNumber;


function prompt8() {
// print someNumber to the console in your function so you can see its value
console.log(someNumber);

// YOUR CODE HERE
let someNumber = Math.floor(Math.random() * 100);
console.log(someNumber);
if(someNumber < 30 && someNumber > 0){
console.log("Thats a small number!");
}
else if(someNumber >= 30 && someNumber < 60){
console.log("The number is medium sized.");
}
else if(someNumber >= 60){
console.log("We got a big one!");
}
}

// COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER!
Expand All @@ -164,6 +200,9 @@ const starWars = ["Han", "C3PO", "R2D2", "Luke", "Leia", "Anakin"];

function prompt9() {
// YOUR CODE HERE
for(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 @@ -180,7 +219,14 @@ function prompt9() {
function prompt10() {
const myArray = [];
// YOUR CODE HERE

let i;
for(i = 0; i <= 100; i++){
if(i% 2 == 0){
myArray[i] = i;

}
}
console.log(myArray);
// 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 @@ -229,13 +275,17 @@ let nums = [
];

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

console.log(median);
console.log(nums.sort());
medianNum = nums.length / 2;
console.log(medianNum);
medianNum = Math.round(medianNum);
console.log(medianNum);
console.log(nums[medianNum]);
}
// COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER!
// prompt11();
//node prompt11();

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

Expand All @@ -254,10 +304,15 @@ 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"

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