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

Control-flow deliverables from Gabriel C. #19

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/Control_Flow_Homework.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 54 additions & 15 deletions lib/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ function prompt1() {
*/

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

}
}

// COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER!
Expand All @@ -50,7 +55,9 @@ 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!
Expand All @@ -65,7 +72,9 @@ 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!
Expand All @@ -79,7 +88,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(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 +106,11 @@ function prompt5() {
*/

function prompt6() {
// YOUR CODE HERE
for(let 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 @@ -114,7 +129,11 @@ 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!
Expand All @@ -135,13 +154,20 @@ function prompt7() {
*/

// define someNumber here
var someNumber;
let someNumber;

function prompt8() {
someNumber = Math.floor(Math.random() * 99) + 1;
if( someNumber < 30) {
console.log("That's a small number!")
}



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

// YOUR CODE HERE

}

// COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER!
Expand Down Expand Up @@ -200,7 +226,7 @@ function prompt10() {
* Hint: What does Math.floor() do?
*/

let nums = [
let arr = [
14,
11,
16,
Expand Down Expand Up @@ -228,12 +254,16 @@ let nums = [
12,
];

function prompt11() {
let median;
// YOUR CODE HERE
function prompt11(arr) {
let sort = Array.from(arr).sort((a, b) => a - b)
let middle = Math.floor(sort.length / 2);

console.log(median);
if (sort.length % 2 === 0) {
return (sort[middle - 1] + sort[middle]) / 2;
}
return sort[middle];
}

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

Expand All @@ -253,7 +283,12 @@ function prompt11() {
*/

function prompt12() {
// YOUR CODE HERE
for (let i = 1; 1 <= 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,7 +309,11 @@ let nestedArrays = [
];

function prompt13() {
// YOUR CODE HERE
for (let i = 0; i < nestedArrays.length; i++) {
for( let j = 0; j < nestedArrays[i].length; j++) {
console.log([i][j])
}
}
}

// COMMENT IN THE BELOW LINE OF CODE TO TEST YOUR OUTPUT IN THE BROWSER!
Expand Down
2 changes: 1 addition & 1 deletion lib/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</head>
<body>
<p>Check in your console</p>
<script src="challenge.js"></script>
<script src="./challenge.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions node_modules/.bin/_mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/esparse

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/esvalidate

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/flat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/he

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/js-yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/nanoid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/node-which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading