diff --git a/src/week1/day0/formHTML.html b/src/week1/day0/formHTML.html new file mode 100644 index 0000000..e69de29 diff --git a/src/week1/day0/listHTML.html b/src/week1/day0/listHTML.html new file mode 100644 index 0000000..d90f830 --- /dev/null +++ b/src/week1/day0/listHTML.html @@ -0,0 +1,17 @@ + + + + + My to do list + + +

To do items

+ + + + \ No newline at end of file diff --git a/src/week1/day0/tableHTML.html b/src/week1/day0/tableHTML.html new file mode 100644 index 0000000..a568a7d --- /dev/null +++ b/src/week1/day0/tableHTML.html @@ -0,0 +1,66 @@ + + + + + My to do list + + + + + + + + + + + + + + + + + + + + + +
To do items
Gasto$$
Mt. LassenCalifornia
Mt. HoodOregon
1980Explosive Eruption
+ + \ No newline at end of file diff --git a/src/week1/days2-5/beanCounting.js b/src/week1/days2-5/beanCounting.js new file mode 100644 index 0000000..2bcb6bc --- /dev/null +++ b/src/week1/days2-5/beanCounting.js @@ -0,0 +1,14 @@ +function countChar(string, ch) { + let cont = 0; + for (let i = 0; i < string.length; i++) { + if (string[i] == ch) { + cont += 1; + } + } + return cont; + } + + function countBs(string) { + return countChar(string, "B"); + } + \ No newline at end of file diff --git a/src/week1/days2-5/chessboard.js b/src/week1/days2-5/chessboard.js new file mode 100644 index 0000000..359808e --- /dev/null +++ b/src/week1/days2-5/chessboard.js @@ -0,0 +1,14 @@ +let salida = ""; + +for (let y = 0; y < 9; y++) { + for (let x = 0; x < 9; x++) { + if ((x + y) % 2 == 0) { + salida += " "; + } else { + salida += "#"; + } + } + salida += "\n"; +} + +console.log(salida); diff --git a/src/week1/days2-5/deepComparison.js b/src/week1/days2-5/deepComparison.js new file mode 100644 index 0000000..93dbc2e --- /dev/null +++ b/src/week1/days2-5/deepComparison.js @@ -0,0 +1,24 @@ +function deepEqual(a, b) { + if (a === b) + return true; + + if (a == null || typeof a != "object" || + b == null || typeof b != "object") { + return false; + } + + let keysA = Object.keys(a), keysB = Object.keys(b); + + if (keysA.length != keysB.length) { + return false; + } + + for (let key of keysA) { + if (!keysB.includes(key) || !deepEqual(a[key], b[key])) { + return false; + } + } + + return true; + } + \ No newline at end of file diff --git a/src/week1/days2-5/exercise.html b/src/week1/days2-5/exercise.html new file mode 100644 index 0000000..9c9fea1 --- /dev/null +++ b/src/week1/days2-5/exercise.html @@ -0,0 +1,10 @@ + + + + + + + +

JavaScript

+ + \ No newline at end of file diff --git a/src/week1/days2-5/fizzBuzz.js b/src/week1/days2-5/fizzBuzz.js new file mode 100644 index 0000000..d4b1e8c --- /dev/null +++ b/src/week1/days2-5/fizzBuzz.js @@ -0,0 +1,9 @@ +for (let n = 1; n <= 100; n++) { + let salida = ""; + if (n % 3 == 0) + salida += "Fizz"; + if (n % 5 == 0) + salida += "Buzz"; + console.log(salida || n); + } + \ No newline at end of file diff --git a/src/week1/days2-5/list.js b/src/week1/days2-5/list.js new file mode 100644 index 0000000..18b4029 --- /dev/null +++ b/src/week1/days2-5/list.js @@ -0,0 +1,30 @@ +function arrayToList(array) { + let list = null; + for (let i = array.length - 1; i >= 0; i--) { + list = {value: array[i], rest: list}; + } + return list; + } + + function listToArray(list) { + let array = []; + for (let node = list; node; node = node.rest) { + array.push(node.value); + } + return array; + } + + function prepend(value, list) { + return {value, rest: list}; + } + + function nth(list, n) { + if (!list) + return undefined; + else + if (n == 0) + return list.value; + else + return nth(list.rest, n - 1); + } + \ No newline at end of file diff --git a/src/week1/days2-5/loopingTriangle.js b/src/week1/days2-5/loopingTriangle.js new file mode 100644 index 0000000..b7c0ba3 --- /dev/null +++ b/src/week1/days2-5/loopingTriangle.js @@ -0,0 +1,2 @@ +for(let hash = "#"; hash.length < 8; hash += "#") + console.log(hash); diff --git a/src/week1/days2-5/minimum.js b/src/week1/days2-5/minimum.js new file mode 100644 index 0000000..57719f9 --- /dev/null +++ b/src/week1/days2-5/minimum.js @@ -0,0 +1,6 @@ +function min(a, b){ + if(a= 0; i--) { + salida.push(array[i]); + } + return salida; + } + + function reverseArrayInPlace(array) { + for (let i = 0; i < Math.floor(array.length / 2); i++) { + let old = array[i]; + array[i] = array[array.length - 1 - i]; + array[array.length - 1 - i] = old; + } + return array; + } + \ No newline at end of file diff --git a/src/week1/days2-5/sumRange.js b/src/week1/days2-5/sumRange.js new file mode 100644 index 0000000..19e8a55 --- /dev/null +++ b/src/week1/days2-5/sumRange.js @@ -0,0 +1,27 @@ +function range(start, end, step) { + let array = []; + + if( start < end ){ + step = 1; + } + else{ + step = -1; + } + + if (step > 0) { + for (let i = start; i <= end; i += step) + array.push(i); + } + else { + for (let i = start; i >= end; i += step) array.push(i); + } + return array; +} + +function sum(array) { + let total = 0; + for (let value of array) { + total += value; + } + return total; +}