From f7d594093f50c209a910b9e3463bec2927351543 Mon Sep 17 00:00:00 2001 From: nirmalaashok Date: Mon, 15 Jan 2024 13:17:37 -0800 Subject: [PATCH 1/5] test --- Week2/homework/maartjes-work.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week2/homework/maartjes-work.js b/Week2/homework/maartjes-work.js index 49772eb44..274eeaf2b 100644 --- a/Week2/homework/maartjes-work.js +++ b/Week2/homework/maartjes-work.js @@ -14,7 +14,7 @@ const monday = [ duration: 20, }, { - name: 'Talk to a lot of people', + name: 'Talk to a lot of people!', duration: 200, }, ]; From e1dec700d0c92bf4bd8ed82426b6baa22ab0adad Mon Sep 17 00:00:00 2001 From: nirmalaashok Date: Thu, 18 Jan 2024 14:34:27 -0800 Subject: [PATCH 2/5] test1 --- Week1/homework/index.html | 14 +- Week2/MAKEME.md | 32 +- Week2/homework/maartjes-work.js | 22 +- Week2/homework/map-filter.js | 6 +- Week2/test/map-filter.test.js | 1 + package-lock.json | 6513 +++++++++++++++++++------------ 6 files changed, 4018 insertions(+), 2570 deletions(-) diff --git a/Week1/homework/index.html b/Week1/homework/index.html index b22147cd1..48da55121 100644 --- a/Week1/homework/index.html +++ b/Week1/homework/index.html @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + Codestin Search App + \ No newline at end of file diff --git a/Week1/homework/style.css b/Week1/homework/style.css index bab13ec23..0ab298753 100644 --- a/Week1/homework/style.css +++ b/Week1/homework/style.css @@ -1 +1,8 @@ -/* add your styling here */ \ No newline at end of file +/* add your styling here +body { + background-color: pink; + text-align: left; + max-width: fit-content; + margin: 0 auto; + font-family: Arial, Helvetica, sans-serif; +} diff --git a/Week2/homework/index.html b/Week2/homework/index.html new file mode 100644 index 000000000..f0a8910f8 --- /dev/null +++ b/Week2/homework/index.html @@ -0,0 +1,22 @@ + + + + + + + Codestin Search App + + + + +
+ + + \ No newline at end of file diff --git a/Week2/homework/maartjes-work.js b/Week2/homework/maartjes-work.js index 0d880b4c1..21cf277fb 100644 --- a/Week2/homework/maartjes-work.js +++ b/Week2/homework/maartjes-work.js @@ -45,16 +45,15 @@ const tuesday = [ const maartjesTasks = monday.concat(tuesday); const maartjesHourlyRate = 20; +const convertToHours = task => task.duration / 60; +const filterTasksWith2Hours = hour => hour >= 2; + function computeEarnings(tasks, hourlyRate) { - return ( - tasks - .map(task => task.duration / 60) - .filter(hour => hour >= 2) - // eslint-disable-next-line no-return-assign - .reduce((acc, cv) => (acc += cv * hourlyRate), 0) - ); + return tasks + .map(convertToHours) + .filter(filterTasksWith2Hours) + .reduce((acc, cv) => acc + cv * hourlyRate, 0); } - // eslint-disable-next-line no-unused-vars const maartjesearnings = computeEarnings(maartjesTasks, maartjesHourlyRate); diff --git a/Week2/homework/pokeapl.jpg b/Week2/homework/pokeapl.jpg new file mode 100644 index 0000000000000000000000000000000000000000..43f65333b84b44705fa141073a8ea9f685aa4bc8 GIT binary patch literal 8369 zcmbt(XHb;Qv+uJkNpgl=GD~J9XAl9A93(6(Iiuv9BuJ2)BuZ4G!m@-VE+8lw78F5( z1d%965JW&h!r?vdt$Y9H%l&eCe$UKwb=P!P%{*P*)z_b|R{$z)buD!O1Ofoi%>b?! zfu{fo5ivbI9U~px&Bq8~ghE)DAUE{S1Z84kf&e zgSY@ZY7m$jbUgqt-#CZ|{>Rn-OZbF%U;+@)jZl{gzysld@d*iu@QLtAZ!~T=fEu5M zlR!+xkdT(k-ZxrY)yOZijED~A5R-+WmoP5B=NOya)H}(o=KqsHvZA@Kf9lif`r*xK zkQ*!i)6zf3;S=15_^EGXczAdq@Qvkv9RcA{gT-h#4e`ZQXjL%;T=vn2bk_?28Tdw# z8cYq`1^!A2XcPQzVMD93FGSX#kKU%M^A@Z>1rJ19h1+T$8ZNQudi77Io;2AmWk`fq zE0{HuIGh{Ywfci)>0w2xHx_sBrV)9WNOxlVRxM6B8P*1{=`d>v70;Yuvqn`qvg zFiw*fb(A#v4!0PrPe_^QVJj#_JXG}=AOt^?`b42`9q{IT`{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p(Ru8=SGLHzR!*-o-!01zL#Lwhc1El-qdH9A;{GIaZH1o8h7IuonyR{1`S#s=$m)&5$K#We;U5cHM)xh4#bBP4Ymd5(!$S_-!%?T=`; z1-o;JI??S1yy(9&PGsRjGGsoJQkxu2Cs|P>>gcvRMF|cR2^?Fl5q#S@$N;7{cP&G@ zC54Z`v`Eb_O%}V(5fmHp&^PI+AqVM8&xRWFr0j0;i{RL5bnQn$b58ppD^0JOAm)Pk zlILIGT5Jf(|A~m;B z$G3_}v2*)kAtuV5II_das@;_7gXF!f<1SkBx2EoB{4|i^%|;H zAJH>YV??L4W_#H9vh^3a^5i0zv!vQdf7Bd*`042NReT=VK9Jg|HlTo*0$zw*Uuc!g+idR4h4Oeydrs78WITDM&tHBoNwlFD6;OfTXN zMtm#pxm<)V>Sj8Qh*hNGQq^@P} z`U=WACqkUwmnM!p1#@kVQyA7db6cEdFy2{t8&9M6IEiE|IeX`i^-6l1=Xbo4%l86o z$)QE$ml0_nMDA-;IxW1>6e$_}j01&kx7I Date: Tue, 23 Jan 2024 12:58:57 -0800 Subject: [PATCH 5/5] finished --- Week3/MAKEME.md | 3 ++- Week3/homework/step2-1.js | 4 +--- Week3/homework/step2-2.js | 19 ++++++++++++++----- Week3/homework/step2-3.js | 29 ++++++++++++++++++++--------- Week3/homework/step2-4.js | 7 +++++-- Week3/homework/step2-5.js | 5 +++++ Week3/homework/step2-6.js | 18 ++++++++++++++---- Week3/homework/step2-7.js | 2 ++ Week3/homework/step3-bonus.js | 5 ++++- Week3/homework/step3.js | 5 +++-- 10 files changed, 70 insertions(+), 27 deletions(-) diff --git a/Week3/MAKEME.md b/Week3/MAKEME.md index 289c6c22d..6f8914386 100644 --- a/Week3/MAKEME.md +++ b/Week3/MAKEME.md @@ -40,7 +40,8 @@ setTimeout(doIt, 5000); ```js function foo(func) { - // What to do here? + // What to + func() } function bar() { diff --git a/Week3/homework/step2-1.js b/Week3/homework/step2-1.js index d5699882c..28fa47a4b 100644 --- a/Week3/homework/step2-1.js +++ b/Week3/homework/step2-1.js @@ -1,9 +1,7 @@ 'use strict'; function foo(func) { - // What to do here? - // Replace this comment and the next line with your code - console.log(func); + func(); } function bar() { diff --git a/Week3/homework/step2-2.js b/Week3/homework/step2-2.js index dcd135040..5e02e4944 100644 --- a/Week3/homework/step2-2.js +++ b/Week3/homework/step2-2.js @@ -2,19 +2,28 @@ function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) { const numbers = []; - - // Replace this comment and the next line with your code - console.log(startIndex, stopIndex, threeCallback, fiveCallback, numbers); + for (let i = startIndex; i <= stopIndex; i++) { + numbers.push(i); + if (i % 3 === 0) { + threeCallback(i); + } + if (i % 5 === 0) { + fiveCallback(i); + } + } + console.log(`Start Index: ${startIndex}, Stop Index: ${stopIndex}`); + console.log('Numbers:', numbers); + return numbers; } function sayThree(number) { // Replace this comment and the next line with your code - console.log(number); + console.log(`${number} is divisible by 3`); } function sayFive(number) { // Replace this comment and the next line with your code - console.log(number); + console.log(`${number} is divisible by 3`); } threeFive(10, 15, sayThree, sayFive); diff --git a/Week3/homework/step2-3.js b/Week3/homework/step2-3.js index 00845c5eb..1b97720b0 100644 --- a/Week3/homework/step2-3.js +++ b/Week3/homework/step2-3.js @@ -1,42 +1,53 @@ 'use strict'; -// Use a 'for' loop +// Use a 'for' function repeatStringNumTimesWithFor(str, num) { // eslint-disable-next-line prefer-const let result = ''; - + for (let i = 0; i < num; i++) { + result += str; + } // Replace this comment and the next line with your code console.log(str, num, result); return result; } - console.log('for', repeatStringNumTimesWithFor('abc', 3)); // Use a 'while' loop function repeatStringNumTimesWithWhile(str, num) { - // eslint-disable-next-line prefer-const let result = ''; - + let i = 0; + // Use a 'while' loop to concatenate the string 'num' times + while (i < num) { + result += str; + i++; + } // Replace this comment and the next line with your code console.log(str, num, result); return result; } - console.log('while', repeatStringNumTimesWithWhile('abc', 3)); // Use a 'do...while' loop function repeatStringNumTimesWithDoWhile(str, num) { - // eslint-disable-next-line prefer-const let result = ''; - // Replace this comment and the next line with your code + // Check if num is greater than 0 before starting the do-while loop + if (num > 0) { + let i = 0; + do { + result += str; + i++; + } while (i < num); + } + + // Log the information about the repetition to the console console.log(str, num, result); return result; } - console.log('do-while', repeatStringNumTimesWithDoWhile('abc', 3)); // Do not change or remove anything below this line diff --git a/Week3/homework/step2-4.js b/Week3/homework/step2-4.js index b11b1dcb6..f923671a5 100644 --- a/Week3/homework/step2-4.js +++ b/Week3/homework/step2-4.js @@ -1,10 +1,13 @@ 'use strict'; function Dog() { - // add your code here + // Properties + this.name = 'Rossy'; + this.color = 'white'; + this.numLegs = 4; } - const hound = new Dog(); +console.log(hound.name, hound.color, hound.numLegs); // Do not change or remove anything below this line module.exports = hound; diff --git a/Week3/homework/step2-5.js b/Week3/homework/step2-5.js index cbb54fa1d..f77af3414 100644 --- a/Week3/homework/step2-5.js +++ b/Week3/homework/step2-5.js @@ -3,6 +3,11 @@ function multiplyAll(arr) { // eslint-disable-next-line let product = 1; + for (let i = 0; i < arr.length; i++) { + for (let j = 0; j < arr[i].length; j++) { + product *= arr[i][j]; + } + } // Replace this comment and the next line with your code console.log(arr, product); diff --git a/Week3/homework/step2-6.js b/Week3/homework/step2-6.js index ffe95b9f7..19ec6acd9 100644 --- a/Week3/homework/step2-6.js +++ b/Week3/homework/step2-6.js @@ -4,15 +4,25 @@ const arr2d = [[1, 2], [3, 4], [5, 6]]; const arr3d = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]; function flattenArray2d(arr) { - // Replace this comment and the next line with your code - console.log(arr); + const flattenedArray2 = arr.reduce((acc, current) => acc.concat(current), []); + return flattenedArray2; } +// Call the function with arr2d and store the result +const flattenedArray2dResult = flattenArray2d(arr2d); +// Log the result +console.log(flattenedArray2dResult); function flattenArray3d(arr) { - // Replace this comment and the next line with your code - console.log(arr); + return arr.flat(Infinity); } +// Call the function with arr3d and store the result +const flattenedArray3 = flattenArray3d(arr3d); + +// Log the result +console.log(flattenedArray3); // -> [1, 2, 3, 4, 5, 6, 7 +// Log the result + console.log(flattenArray2d(arr2d)); // -> [1, 2, 3, 4, 5, 6] console.log(flattenArray3d(arr3d)); // -> [1, 2, 3, 4, 5, 6, 7, 8] diff --git a/Week3/homework/step2-7.js b/Week3/homework/step2-7.js index 3e72e8551..550d6fce8 100644 --- a/Week3/homework/step2-7.js +++ b/Week3/homework/step2-7.js @@ -21,3 +21,5 @@ f2(y); console.log(y); // Add your explanation as a comment here +// variable x is a primitive date type number when function f1 inside val it will not affect the original value of x +// variable y is object when passes to f2 function so it will affect the original value of x diff --git a/Week3/homework/step3-bonus.js b/Week3/homework/step3-bonus.js index 917091d61..57dfe07f6 100644 --- a/Week3/homework/step3-bonus.js +++ b/Week3/homework/step3-bonus.js @@ -3,8 +3,11 @@ const values = ['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c']; function makeUnique(arr) { - // Replace this comment and the next line with your code console.log(arr); + const outputArray = arr.filter(function(v, i, self) { + return i === self.indexOf(v); + }); + return outputArray; // Return the modified array with duplicates removed } const uniqueValues = makeUnique(values); diff --git a/Week3/homework/step3.js b/Week3/homework/step3.js index 292724bf4..ff1e64bfc 100644 --- a/Week3/homework/step3.js +++ b/Week3/homework/step3.js @@ -1,8 +1,9 @@ 'use strict'; function createBase(base) { - // Replace this comment and the next line with your code - console.log(base); + return function(number) { + return base + number; + }; } const addSix = createBase(6);