From 0fae10a542bf0ee1865d8a771d1d521fb6c28ca1 Mon Sep 17 00:00:00 2001 From: CWilliams75 Date: Sun, 29 Nov 2020 20:29:43 -0500 Subject: [PATCH 1/3] for loop --- index.html | 11 +++++++++++ loops.js | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 index.html create mode 100644 loops.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..1362f07 --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/loops.js b/loops.js new file mode 100644 index 0000000..acf8791 --- /dev/null +++ b/loops.js @@ -0,0 +1,3 @@ +for (let i = 1; i <=10; i++) { + console.log (i) +} \ No newline at end of file From 70faf8ae11bbbe46cfe6348ea3f86c72ae6ad7ce Mon Sep 17 00:00:00 2001 From: CWilliams75 Date: Sun, 29 Nov 2020 21:51:04 -0500 Subject: [PATCH 2/3] problem 2 - 6 --- loops.js | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/loops.js b/loops.js index acf8791..91f0a20 100644 --- a/loops.js +++ b/loops.js @@ -1,3 +1,34 @@ +/*Problem 1 +for (i = 1; i <= 10; i++){ + console.log(i)*/ + +/*Problem 2 for (let i = 1; i <=10; i++) { - console.log (i) -} \ No newline at end of file + console.log(i * i); +}*/ + +/*Problem 3 +let n = 20 + for (i = 1; i <= n; i++) { + if (i % 2 == 0) { + console.log(i) + } +}*/ + +/*Problem 5 +do { + user = prompt("Are we there yet") +}while (user !== "Yes") +alert("Good!") */ + + + +//Problem 6 + +/*for (let i = 1; i <= 5; i++) { + let stars = "" + for (let j = 1; j <= i; j++) + stars += "*"; + + console.log(stars); +}*/ \ No newline at end of file From 74efa6b35cbfb2e22caa35c0feb1e7ac9bc07bdf Mon Sep 17 00:00:00 2001 From: CWilliams75 Date: Sun, 29 Nov 2020 23:11:41 -0500 Subject: [PATCH 3/3] loops completed --- loops.js | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/loops.js b/loops.js index 91f0a20..0d6c23b 100644 --- a/loops.js +++ b/loops.js @@ -31,4 +31,46 @@ alert("Good!") */ stars += "*"; console.log(stars); -}*/ \ No newline at end of file +}*/ + +//Problem 7 +/*rows = 4 +columns = 4 + +for (let currentRow = 1; currentRow <= rows; currentRow++) { + let num = "" + for (let currentCol = 1; currentCol <= columns; currentCol++){ + let product = "" + product += currentCol * currentRow + if (currentCol === 1){ + num += `|` + } + if (product < 10 && currentCol > 1) { + num += ` ${product} |` + } else { + num += ` ${product} |` + } + } + console.log(num) +}*/ + +//Problem 8 +rows = 6 +columns = 6 + +for (let currentRow = 1; currentRow <= rows; currentRow++) { + let num = "" + for (let currentCol = 1; currentCol <= columns; currentCol++){ + let product = "" + product += currentCol * currentRow + if (currentCol === 1){ + num += `|` + } + if (product < 10 && currentCol > 1) { + num += ` ${product} |` + } else { + num += ` ${product} |` + } + } + console.log(num) +} \ No newline at end of file