From 7f7479af33ebe36a53f0685232b1878b2a56dbac Mon Sep 17 00:00:00 2001 From: VincentHan12 Date: Wed, 25 Jun 2025 17:15:51 +1200 Subject: [PATCH 01/17] complete first task.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b66702018..46298caef 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ The recommended time is how much time you should spend on that task. If you find ## Contents -- [ ] 1. [Initial Set Up](/1-SetUp/README.md) (1.5hrs) +- [x] 1. [Initial Set Up](/1-SetUp/README.md) (1.5hrs) - [ ] 2. [Basics](/2-Basics/README.md) (7hrs) - [ ] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs) - [ ] 4. [Basic React](/4-React/README.md) (8hrs) From f6690257950b42f723a3cd0430ec6d63c81b99ab Mon Sep 17 00:00:00 2001 From: VincentHan12 Date: Wed, 25 Jun 2025 17:19:08 +1200 Subject: [PATCH 02/17] complete first task.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b66702018..46298caef 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ The recommended time is how much time you should spend on that task. If you find ## Contents -- [ ] 1. [Initial Set Up](/1-SetUp/README.md) (1.5hrs) +- [x] 1. [Initial Set Up](/1-SetUp/README.md) (1.5hrs) - [ ] 2. [Basics](/2-Basics/README.md) (7hrs) - [ ] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs) - [ ] 4. [Basic React](/4-React/README.md) (8hrs) From 25f383ccd9789dc49d1ff9af1fa785dea4dafbf2 Mon Sep 17 00:00:00 2001 From: VincentHan12 Date: Tue, 15 Jul 2025 12:18:36 +1200 Subject: [PATCH 03/17] Basics Done.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 46298caef..9a2e74cd4 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The recommended time is how much time you should spend on that task. If you find ## Contents - [x] 1. [Initial Set Up](/1-SetUp/README.md) (1.5hrs) -- [ ] 2. [Basics](/2-Basics/README.md) (7hrs) +- [x] 2. [Basics](/2-Basics/README.md) (7hrs) - [ ] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs) - [ ] 4. [Basic React](/4-React/README.md) (8hrs) - [ ] 5. [Build your first react app](/5-MyFirstApp/README.md) (4hrs +) From 8cfd62b71cc8f631edc32dc8c03afdb01fc29b21 Mon Sep 17 00:00:00 2001 From: Vincent Han Date: Tue, 15 Jul 2025 01:31:10 +0000 Subject: [PATCH 04/17] complete second task --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 46298caef..9a2e74cd4 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The recommended time is how much time you should spend on that task. If you find ## Contents - [x] 1. [Initial Set Up](/1-SetUp/README.md) (1.5hrs) -- [ ] 2. [Basics](/2-Basics/README.md) (7hrs) +- [x] 2. [Basics](/2-Basics/README.md) (7hrs) - [ ] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs) - [ ] 4. [Basic React](/4-React/README.md) (8hrs) - [ ] 5. [Build your first react app](/5-MyFirstApp/README.md) (4hrs +) From a41163da54e92ae26e90d2c3e129624d289b4091 Mon Sep 17 00:00:00 2001 From: VincentHan12 Date: Tue, 15 Jul 2025 15:42:57 +1200 Subject: [PATCH 05/17] Update README.md From 4464a5f5f616aa3bf207a6467f9d1972147ee007 Mon Sep 17 00:00:00 2001 From: VincentHan12 Date: Thu, 17 Jul 2025 11:00:16 +1200 Subject: [PATCH 06/17] Update README.md --- 3-JSKata/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3-JSKata/README.md b/3-JSKata/README.md index 792849fe7..d6c99a8fb 100644 --- a/3-JSKata/README.md +++ b/3-JSKata/README.md @@ -82,7 +82,7 @@ If things aren't working as you are expecting, `console.log` out the variables a ## Exercises -- [ ] [Object and arrays](./1-objects-and-arrays/README.md) (2hrs) +- [x] [Object and arrays](./1-objects-and-arrays/README.md) (2hrs) - [ ] [Strings and numbers](./2-strings-and-numbers/README.md) (2hrs) - [ ] [Data structures](./3-data-structures/README.md) (2hrs) - [ ] [Types](./4-types/README.md) (2hrs) From 28e3eea0aec276f5da2d58c683a9a7badfa66019 Mon Sep 17 00:00:00 2001 From: VincentHan12 Date: Thu, 17 Jul 2025 16:51:32 +1200 Subject: [PATCH 07/17] JSKata completed task 2.md --- 3-JSKata/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3-JSKata/README.md b/3-JSKata/README.md index d6c99a8fb..abd1dd378 100644 --- a/3-JSKata/README.md +++ b/3-JSKata/README.md @@ -83,7 +83,7 @@ If things aren't working as you are expecting, `console.log` out the variables a ## Exercises - [x] [Object and arrays](./1-objects-and-arrays/README.md) (2hrs) -- [ ] [Strings and numbers](./2-strings-and-numbers/README.md) (2hrs) +- [x] [Strings and numbers](./2-strings-and-numbers/README.md) (2hrs) - [ ] [Data structures](./3-data-structures/README.md) (2hrs) - [ ] [Types](./4-types/README.md) (2hrs) From 407e3202ccd6b6e3e2d3d453c07e324ed126ed62 Mon Sep 17 00:00:00 2001 From: Vincent Han Date: Mon, 21 Jul 2025 07:00:55 +0000 Subject: [PATCH 08/17] Test 2 Completed --- 3-JSKata/2-strings-and-numbers/utilities.js | 56 +++++++++++++++++---- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/3-JSKata/2-strings-and-numbers/utilities.js b/3-JSKata/2-strings-and-numbers/utilities.js index 5ce1008ce..51fa2019b 100644 --- a/3-JSKata/2-strings-and-numbers/utilities.js +++ b/3-JSKata/2-strings-and-numbers/utilities.js @@ -1,24 +1,58 @@ -function getType(thing) {} +function getType(thing) { + return typeof thing +} -function isNumber(thing) {} +function isNumber(thing) { + return typeof thing == 'number' +} -function toNumber(str) {} +function toNumber(str) { + return Number(str) +} -function isStringNumber(str) {} +function isStringNumber(str) { + return typeof str == 'string' && !isNaN(str) +} -function add(a, b) {} +function add(a, b) { + return a + b +} -function addStrings(a, b) {} +function addStrings(a, b) { + return String(Number(a) + Number(b)) +} -function addStringsOrNumbers(a, b) {} +function addStringsOrNumbers(a, b) { + if (typeof a == 'number' && typeof b == 'number') { + return a + b + } else { + return String(Number(a) + Number(b)) + } +} -function isEmail(str) {} +function isEmail(str) { + console.log + const emailRegex = /.+@.+\..+/ + return emailRegex.test(str) +} -function countIf(array, fn) {} +function countIf(array, fn) { + count = 0 + for (item of array) { + if (fn(item)) { + count++ + } + } + return count +} -function filterStringsWithCommas(str) {} +function filterStringsWithCommas(str) { + return str.includes(',') +} -function splitStringByCommas(str) {} +function splitStringByCommas(str) { + return str.split(',') +} module.exports = { getType, From d956f4a7244e497ffdb57e66269408fef045ddd9 Mon Sep 17 00:00:00 2001 From: Vincent Han Date: Mon, 21 Jul 2025 07:06:47 +0000 Subject: [PATCH 09/17] Test 1 Complete --- 3-JSKata/1-objects-and-arrays/kata.js | 147 ++++++++++++++++++++++---- 1 file changed, 126 insertions(+), 21 deletions(-) diff --git a/3-JSKata/1-objects-and-arrays/kata.js b/3-JSKata/1-objects-and-arrays/kata.js index ef4a67342..04ea1798d 100644 --- a/3-JSKata/1-objects-and-arrays/kata.js +++ b/3-JSKata/1-objects-and-arrays/kata.js @@ -4,46 +4,79 @@ // getGreeting should return a string containing // 'Hello ' and the contents of `name` -function getGreeting(name) {} +function getGreeting(name) { + return 'Hello ' + name +} // ageOneYear should return a new object with an `age` property 1 greater // than the `age` property of `obj` -function ageOneYear(obj) {} +function ageOneYear(obj) { + console.log(obj) + let newObj = { + ...obj, + age: obj['age'] + 1, + } + console.log(newObj) + + return newObj +} // makeObject should return an object that looks like this: // (but using the arguments passed to the function) // { // key: value // } -function makeObject(key, value) {} +function makeObject(key, value) { + return { [key]: value } +} // getPropertyValue should return the value of the // property contained in the `key` of `obj` -function getPropertyValue(obj, key) {} +function getPropertyValue(obj, key) { + return obj[key] +} // addName should return a copy of `obj` with the addition of a `name` // property that has the value of the `name` argument // Tip: consider the object literal spread syntax -function addName(obj, name) {} +function addName(obj, name) { + let newObj = { + ...obj, + name: name, + } + return newObj +} // deleteProperty should return a new copy of `obj` without the property name // that matches the `key` parameter // Tip: consider JavaScript's `delete` operator -function deleteProperty(obj, key) {} +function deleteProperty(obj, key) { + let newObj = { ...obj } + delete newObj[key] + return newObj +} // returnErrorIfFalsy should return a JavaScript Error object with message: // 'Oh no, an error!' // if val evaluates to false // Tip: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error -function returnErrorIfFalsy(val) {} +function returnErrorIfFalsy(val) { + if (val == false) { + return Error('Oh no, an error!') + } +} // keys should return an array of the object's property names (keys) // For example, given { foo: 1, bar: 2 } it would return ['foo', 'bar'] -function getKeys(obj) {} +function getKeys(obj) { + return Object.keys(obj) +} // getValues should return an array of the object's own values // For example, given { foo: 1, bar: 2 } it would return [1, 2] -function getValues(obj) {} +function getValues(obj) { + return Object.values(obj) +} /** * Arrays @@ -52,57 +85,129 @@ function getValues(obj) {} // makeArrayOfItem should return an array that is `length` long, made up of // `item`. For example, makeArrayOfItem('foo', 2) would return: // ['foo', 'foo'] -function makeArrayOfItem(item, length) {} +function makeArrayOfItem(item, length) { + let newArray = [] + let count = 1 + while (count <= length) { + newArray.push(item) + count++ + } + return newArray +} // makeArrayOfItems should return an array containing all arguments passed to it // Tip: consider JavaScript's Rest parameters -function makeArrayOfItems() {} +function makeArrayOfItems() { + let newArray = [...arguments] + return newArray +} // hasItem should return true if `item` is present in `arr` at least once, // otherwise it should return false. // Tip: there is an array function that makes this straightforward -function hasItem(arr, item) {} +function hasItem(arr, item) { + return arr.includes(item) +} // getItemAtIndex should return arr[idx] but only if that index exists: // if it doesn't, return a JavaScript Error object. -function getItemAtIndex(arr, idx) {} +function getItemAtIndex(arr, idx) { + if (arr[idx]) { + return arr[idx] + } else { + return Error() + } +} // replaceItemAtIndex should return a copy of `arr` with // the element at `idx` replaced with `item` // Tip: consider the array literal spread syntax -function replaceItemAtIndex(arr, idx, item) {} +function replaceItemAtIndex(arr, idx, item) { + let newArr = [...arr] + newArr[idx] = item + return newArr +} // insertItemAtIndex should return a copy of `arr` with `item` inserted at // `idx` without overwriting any array values (the array should get longer) -function insertItemAtIndex(arr, item, idx) {} +function insertItemAtIndex(arr, item, idx) { + let newArr = [...arr] + newArr.splice(idx, 0, item) + return newArr +} // deleteItemAtIndex should return a copy of `arr` without // the element at `idx` (the array should get shorter). -function deleteItemAtIndex(arr, idx) {} +function deleteItemAtIndex(arr, idx) { + let newArr = [...arr] + newArr.splice(idx, 1) + return newArr +} // deleteItem should return an array with every instance of `item` removed -function deleteItem(arr, item) {} +function deleteItem(arr, item) { + let newArr = [] + for (i in arr) { + if (arr[i] != item) { + newArr.push(arr[i]) + } + } + return newArr +} // zipObject should return an object built from two arrays // For example, given ['foo', 'bar'] and [1, 2] it would return // { foo: 1, bar: 2 } -function zipObject(keys, values) {} +function zipObject(keys, values) { + let newObj = {} + for (i in keys) { + newObj[keys[i]] = values[i] + } + return newObj +} // unzipObject should return an array of arrays, each one a pair of keys and values // For example, given {foo: 1, bar: 2} it would return // [['foo', 1], ['bar', 2]] -function unzipObject(obj) {} +function unzipObject(obj) { + newArr = [] + objKeys = Object.keys(obj) + objValues = Object.values(obj) + for (i in objKeys) { + let info = [objKeys[i], objValues[i]] + newArr.push(info) + } + return newArr +} // findOneByProperty should return an object from `arr` that has the // property AND value of `search`. For example, given: // [{a: 1}, {b: 2, c: 3}] and {b: 2} // it will return: // {b: 2, c: 3} -function findOneByProperty(arr, search) {} +function findOneByProperty(arr, search) { + let key = Object.keys(search)[0] + let value = search[key] + for (obj of arr) { + if (obj[key] == value) { + return obj + } + } +} // findAll should return an array containing all objects in `arr` that // have the property and value of `search` -function findAll(arr, search) {} +function findAll(arr, search) { + let newArr = [] + let key = Object.keys(search)[0] + let value = search[key] + for (obj of arr) { + if (obj[key] == value) { + newArr.push(obj) + } + } + return newArr +} module.exports = { addName, From 19e9083e5ba0ceea2a2cfde4d7e00744bcb5bc13 Mon Sep 17 00:00:00 2001 From: Vincent Han Date: Mon, 21 Jul 2025 07:08:47 +0000 Subject: [PATCH 10/17] settings update --- .vscode/settings.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 94fdbe6e2..b65a4494a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,7 +5,9 @@ "editor.detectIndentation": false, "editor.insertSpaces": true, "editor.tabSize": 2, - "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, "editor.bracketPairColorization.enabled": true, "editor.guides.bracketPairs": "active", "[javascript]": { From cc71a3e4ade1ab4b018552cfc68c5897b05f1385 Mon Sep 17 00:00:00 2001 From: Vincent Han Date: Mon, 21 Jul 2025 13:20:41 +0000 Subject: [PATCH 11/17] Test 3 Complete --- 3-JSKata/3-data-structures/find.js | 5 ++++- 3-JSKata/3-data-structures/getPropTypes.js | 8 +++++++- 3-JSKata/3-data-structures/getType.js | 4 +++- 3-JSKata/3-data-structures/getValue.js | 4 +++- 3-JSKata/3-data-structures/matrix.js | 16 ++++++++++++++-- 3-JSKata/3-data-structures/positions.js | 8 ++++++-- 3-JSKata/3-data-structures/where.js | 21 ++++++++++++++++++++- 7 files changed, 57 insertions(+), 9 deletions(-) diff --git a/3-JSKata/3-data-structures/find.js b/3-JSKata/3-data-structures/find.js index 73dadfc97..2674b2320 100644 --- a/3-JSKata/3-data-structures/find.js +++ b/3-JSKata/3-data-structures/find.js @@ -1,3 +1,6 @@ -function find(arr, searchDetails) {} +function find(arr, searchDetails) { + searchKey = Object.keys(searchDetails)[0] + return arr.find((obj) => obj[searchKey] == searchDetails[searchKey]) +} module.exports = find diff --git a/3-JSKata/3-data-structures/getPropTypes.js b/3-JSKata/3-data-structures/getPropTypes.js index bdcb34a81..86aad43dc 100644 --- a/3-JSKata/3-data-structures/getPropTypes.js +++ b/3-JSKata/3-data-structures/getPropTypes.js @@ -1,3 +1,9 @@ -function getPropTypes(obj) {} +function getPropTypes(obj) { + let propTypes = [] + for (i in obj) { + propTypes.push(typeof obj[i]) + } + return propTypes +} module.exports = getPropTypes diff --git a/3-JSKata/3-data-structures/getType.js b/3-JSKata/3-data-structures/getType.js index 7300746a7..305be5ad7 100644 --- a/3-JSKata/3-data-structures/getType.js +++ b/3-JSKata/3-data-structures/getType.js @@ -1,3 +1,5 @@ -function getType(thing) {} +function getType(thing) { + return typeof thing +} module.exports = getType diff --git a/3-JSKata/3-data-structures/getValue.js b/3-JSKata/3-data-structures/getValue.js index a2ce34fd5..6859439d0 100644 --- a/3-JSKata/3-data-structures/getValue.js +++ b/3-JSKata/3-data-structures/getValue.js @@ -1,3 +1,5 @@ -function getValue(obj, key) {} +function getValue(obj, key) { + return obj[key] +} module.exports = getValue diff --git a/3-JSKata/3-data-structures/matrix.js b/3-JSKata/3-data-structures/matrix.js index f4e7dcde6..a9ae18248 100644 --- a/3-JSKata/3-data-structures/matrix.js +++ b/3-JSKata/3-data-structures/matrix.js @@ -1,6 +1,18 @@ -function getMatrix(n) {} +function getMatrix(n) { + let newMatrix = [] + for (let i = 0; i < n; i++) { + const row = Array(n).fill(0) + newMatrix.push(row) + } + return newMatrix +} -function updateMatrix(matrix, coords, value) {} +function updateMatrix(matrix, coords, value) { + const x = coords[0] + const y = coords[1] + matrix[x][y] = value + return matrix +} module.exports = { getMatrix, diff --git a/3-JSKata/3-data-structures/positions.js b/3-JSKata/3-data-structures/positions.js index 01f59b654..cdbfca5e4 100644 --- a/3-JSKata/3-data-structures/positions.js +++ b/3-JSKata/3-data-structures/positions.js @@ -1,6 +1,10 @@ -function getFirst(arr) {} +function getFirst(arr) { + return arr[0] +} -function getLast(arr) {} +function getLast(arr) { + return arr[arr.length - 1] +} module.exports = { getFirst, diff --git a/3-JSKata/3-data-structures/where.js b/3-JSKata/3-data-structures/where.js index 6a2bdc3b8..c6003eda4 100644 --- a/3-JSKata/3-data-structures/where.js +++ b/3-JSKata/3-data-structures/where.js @@ -1,3 +1,22 @@ -function where(arr, searchDetails) {} +function where(arr, searchDetails) { + let newArr = [] + const searchKey = Object.keys(searchDetails) + + for (obj of arr) { + let match = true + + for (i in searchKey) { + if (obj[searchKey[i]] != searchDetails[searchKey[i]]) { + match = false + } + } + + if (match) { + newArr.push(obj) + } + } + console.log(newArr) + return newArr +} module.exports = where From 202c6a331189ed6ab10325486741bfb8a9b09863 Mon Sep 17 00:00:00 2001 From: VincentHan12 Date: Tue, 22 Jul 2025 01:23:11 +1200 Subject: [PATCH 12/17] Task 3 Data Structures Complete.md --- 3-JSKata/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3-JSKata/README.md b/3-JSKata/README.md index abd1dd378..10295b758 100644 --- a/3-JSKata/README.md +++ b/3-JSKata/README.md @@ -84,7 +84,7 @@ If things aren't working as you are expecting, `console.log` out the variables a - [x] [Object and arrays](./1-objects-and-arrays/README.md) (2hrs) - [x] [Strings and numbers](./2-strings-and-numbers/README.md) (2hrs) -- [ ] [Data structures](./3-data-structures/README.md) (2hrs) +- [x] [Data structures](./3-data-structures/README.md) (2hrs) - [ ] [Types](./4-types/README.md) (2hrs)
From e4ee3d20b6fa994ccf14f30840d19991f7f3f394 Mon Sep 17 00:00:00 2001 From: Vincent Han Date: Mon, 21 Jul 2025 13:33:19 +0000 Subject: [PATCH 13/17] Update Task 3 --- 3-JSKata/1-objects-and-arrays/kata.js | 30 +++++---------------- 3-JSKata/2-strings-and-numbers/utilities.js | 2 +- 3-JSKata/3-data-structures/getPropTypes.js | 2 +- 3-JSKata/3-data-structures/where.js | 4 +-- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/3-JSKata/1-objects-and-arrays/kata.js b/3-JSKata/1-objects-and-arrays/kata.js index 04ea1798d..dc040a2c5 100644 --- a/3-JSKata/1-objects-and-arrays/kata.js +++ b/3-JSKata/1-objects-and-arrays/kata.js @@ -86,20 +86,13 @@ function getValues(obj) { // `item`. For example, makeArrayOfItem('foo', 2) would return: // ['foo', 'foo'] function makeArrayOfItem(item, length) { - let newArray = [] - let count = 1 - while (count <= length) { - newArray.push(item) - count++ - } - return newArray + return Array(length).fill(item) } // makeArrayOfItems should return an array containing all arguments passed to it // Tip: consider JavaScript's Rest parameters function makeArrayOfItems() { - let newArray = [...arguments] - return newArray + return [...arguments] } // hasItem should return true if `item` is present in `arr` at least once, @@ -147,7 +140,7 @@ function deleteItemAtIndex(arr, idx) { // deleteItem should return an array with every instance of `item` removed function deleteItem(arr, item) { let newArr = [] - for (i in arr) { + for (const i in arr) { if (arr[i] != item) { newArr.push(arr[i]) } @@ -160,7 +153,7 @@ function deleteItem(arr, item) { // { foo: 1, bar: 2 } function zipObject(keys, values) { let newObj = {} - for (i in keys) { + for (const i in keys) { newObj[keys[i]] = values[i] } return newObj @@ -170,14 +163,7 @@ function zipObject(keys, values) { // For example, given {foo: 1, bar: 2} it would return // [['foo', 1], ['bar', 2]] function unzipObject(obj) { - newArr = [] - objKeys = Object.keys(obj) - objValues = Object.values(obj) - for (i in objKeys) { - let info = [objKeys[i], objValues[i]] - newArr.push(info) - } - return newArr + return Object.entries(obj) } // findOneByProperty should return an object from `arr` that has the @@ -188,11 +174,7 @@ function unzipObject(obj) { function findOneByProperty(arr, search) { let key = Object.keys(search)[0] let value = search[key] - for (obj of arr) { - if (obj[key] == value) { - return obj - } - } + return arr.find((obj) => obj[key] == value) } // findAll should return an array containing all objects in `arr` that diff --git a/3-JSKata/2-strings-and-numbers/utilities.js b/3-JSKata/2-strings-and-numbers/utilities.js index 51fa2019b..ca348f566 100644 --- a/3-JSKata/2-strings-and-numbers/utilities.js +++ b/3-JSKata/2-strings-and-numbers/utilities.js @@ -38,7 +38,7 @@ function isEmail(str) { function countIf(array, fn) { count = 0 - for (item of array) { + for (const item of array) { if (fn(item)) { count++ } diff --git a/3-JSKata/3-data-structures/getPropTypes.js b/3-JSKata/3-data-structures/getPropTypes.js index 86aad43dc..f0c315835 100644 --- a/3-JSKata/3-data-structures/getPropTypes.js +++ b/3-JSKata/3-data-structures/getPropTypes.js @@ -1,6 +1,6 @@ function getPropTypes(obj) { let propTypes = [] - for (i in obj) { + for (const i in obj) { propTypes.push(typeof obj[i]) } return propTypes diff --git a/3-JSKata/3-data-structures/where.js b/3-JSKata/3-data-structures/where.js index c6003eda4..8f6605d80 100644 --- a/3-JSKata/3-data-structures/where.js +++ b/3-JSKata/3-data-structures/where.js @@ -2,10 +2,10 @@ function where(arr, searchDetails) { let newArr = [] const searchKey = Object.keys(searchDetails) - for (obj of arr) { + for (const obj of arr) { let match = true - for (i in searchKey) { + for (const i in searchKey) { if (obj[searchKey[i]] != searchDetails[searchKey[i]]) { match = false } From b09e2f773ce6abd423cd7a75770f48b392e4fa04 Mon Sep 17 00:00:00 2001 From: Vincent Han Date: Mon, 8 Sep 2025 09:48:22 +0000 Subject: [PATCH 14/17] complete third task --- 3-JSKata/4-types/functions.js | 41 +++++++++++++++++++++++++++++++++++ 3-JSKata/4-types/types.js | 34 +++++++++++++++++++++++++++++ 3-JSKata/README.md | 2 +- README.md | 2 +- 4 files changed, 77 insertions(+), 2 deletions(-) diff --git a/3-JSKata/4-types/functions.js b/3-JSKata/4-types/functions.js index e69de29bb..30fd99d69 100644 --- a/3-JSKata/4-types/functions.js +++ b/3-JSKata/4-types/functions.js @@ -0,0 +1,41 @@ +function callsFunction(func) { + func() +} + +function callsProperty(obj) { + obj.increment() +} + +function filter(arr, func) { + const elements = [] + for (i in arr) { + if (func(arr[i])) { + elements.push(arr[i]) + } + } + return elements +} + +function find(arr, func) { + for (i in arr) { + if (func(arr[i])) { + return arr[i] + } + } +} + +function map(arr, func) { + const elements = [] + for (i in arr) { + elements.push(func(arr[i])) + } + return elements +} + +module.exports = { + callsFunction, + callsProperty, + filter, + find, + map, +} diff --git a/3-JSKata/4-types/types.js b/3-JSKata/4-types/types.js index e69de29bb..5fe0f05b1 100644 --- a/3-JSKata/4-types/types.js +++ b/3-JSKata/4-types/types.js @@ -0,0 +1,34 @@ +function getBoolean() { + return true +} + +function getFunction() { + return function () { + return + } +} + +function getNull() { + return null +} + +function getNumber() { + return 1 +} + +function getObject() { + return { 1: 1, 2: 2 } +} + +function getString() { + return 'hi' +} + +module.exports = { + getBoolean, + getFunction, + getNull, + getNumber, + getObject, + getString, +} diff --git a/3-JSKata/README.md b/3-JSKata/README.md index 10295b758..5661d8786 100644 --- a/3-JSKata/README.md +++ b/3-JSKata/README.md @@ -85,7 +85,7 @@ If things aren't working as you are expecting, `console.log` out the variables a - [x] [Object and arrays](./1-objects-and-arrays/README.md) (2hrs) - [x] [Strings and numbers](./2-strings-and-numbers/README.md) (2hrs) - [x] [Data structures](./3-data-structures/README.md) (2hrs) -- [ ] [Types](./4-types/README.md) (2hrs) +- [x] [Types](./4-types/README.md) (2hrs)
diff --git a/README.md b/README.md index 9a2e74cd4..e81c93121 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The recommended time is how much time you should spend on that task. If you find - [x] 1. [Initial Set Up](/1-SetUp/README.md) (1.5hrs) - [x] 2. [Basics](/2-Basics/README.md) (7hrs) -- [ ] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs) +- [x] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs) - [ ] 4. [Basic React](/4-React/README.md) (8hrs) - [ ] 5. [Build your first react app](/5-MyFirstApp/README.md) (4hrs +) From 4f566f134d5b156dffe5f65d31cdf7f4119af271 Mon Sep 17 00:00:00 2001 From: Vincent Han Date: Tue, 28 Oct 2025 05:30:47 +0000 Subject: [PATCH 15/17] Task 4 Completed --- 4-React/src/components/Dog/Dog.jsx | 19 +++++++++++++ 4-React/src/components/Dog/index.js | 1 + 4-React/src/components/DogList/DogList.jsx | 11 ++++++++ 4-React/src/components/DogList/index.js | 1 + 4-React/src/components/Main/Main.jsx | 28 +++++++++++++++++++- 4-React/src/components/Subtitle/Subtitle.jsx | 7 +++++ 4-React/src/components/Subtitle/index.js | 1 + package-lock.json | 6 +++++ 8 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 4-React/src/components/Dog/Dog.jsx create mode 100644 4-React/src/components/Dog/index.js create mode 100644 4-React/src/components/DogList/DogList.jsx create mode 100644 4-React/src/components/DogList/index.js create mode 100644 4-React/src/components/Subtitle/Subtitle.jsx create mode 100644 4-React/src/components/Subtitle/index.js create mode 100644 package-lock.json diff --git a/4-React/src/components/Dog/Dog.jsx b/4-React/src/components/Dog/Dog.jsx new file mode 100644 index 000000000..d7705725f --- /dev/null +++ b/4-React/src/components/Dog/Dog.jsx @@ -0,0 +1,19 @@ +export function Dog(props) { + const imageBreed = props.breed.charAt(0).toLowerCase() + props.breed.slice(1) + return ( +
+
+ {props.breed} +
+ {props.name} + {props.breed} +
+ {props.superpower} +
+
+ ) +} diff --git a/4-React/src/components/Dog/index.js b/4-React/src/components/Dog/index.js new file mode 100644 index 000000000..cebba49da --- /dev/null +++ b/4-React/src/components/Dog/index.js @@ -0,0 +1 @@ +export { Dog } from './Dog' diff --git a/4-React/src/components/DogList/DogList.jsx b/4-React/src/components/DogList/DogList.jsx new file mode 100644 index 000000000..7f50612fa --- /dev/null +++ b/4-React/src/components/DogList/DogList.jsx @@ -0,0 +1,11 @@ +import { Dog } from '../Dog' + +export function DogList(props) { + return ( + <> + {props.dogs.map((dog) => ( + + ))} + + ) +} diff --git a/4-React/src/components/DogList/index.js b/4-React/src/components/DogList/index.js new file mode 100644 index 000000000..6b4cf2201 --- /dev/null +++ b/4-React/src/components/DogList/index.js @@ -0,0 +1 @@ +export { DogList } from './DogList' diff --git a/4-React/src/components/Main/Main.jsx b/4-React/src/components/Main/Main.jsx index dba185cc4..af62c00e1 100644 --- a/4-React/src/components/Main/Main.jsx +++ b/4-React/src/components/Main/Main.jsx @@ -1,5 +1,31 @@ +import { Dog } from '../Dog' +import { DogList } from '../DogList' import { Logo } from '../Logo' +import { Subtitle } from '../Subtitle' export function Main() { - return + const dogs = [ + { + name: 'Sofia', + breed: 'Greyhound', + superpower: 'Shoots laser beams out of her eyes', + }, + { + name: 'Desdemona', + breed: 'Bulldog', + superpower: 'Heat vision', + }, + { + name: 'Brandon', + breed: 'Dachshund', + superpower: 'Super-screaming', + }, + ] + return ( +
+ + + +
+ ) } diff --git a/4-React/src/components/Subtitle/Subtitle.jsx b/4-React/src/components/Subtitle/Subtitle.jsx new file mode 100644 index 000000000..6a65d3e40 --- /dev/null +++ b/4-React/src/components/Subtitle/Subtitle.jsx @@ -0,0 +1,7 @@ +export function Subtitle(props) { + return ( +

+ {props.text} +

+ ) +} diff --git a/4-React/src/components/Subtitle/index.js b/4-React/src/components/Subtitle/index.js new file mode 100644 index 000000000..0178be6d2 --- /dev/null +++ b/4-React/src/components/Subtitle/index.js @@ -0,0 +1 @@ +export { Subtitle } from './Subtitle' diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..d9fb0e213 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "react-prep", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} From 422bb7c5d24059ac6e024fc62a79fac0ee9de466 Mon Sep 17 00:00:00 2001 From: Vincent Han Date: Wed, 5 Nov 2025 06:34:19 +0000 Subject: [PATCH 16/17] first commit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e81c93121..0d7ae94f1 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,4 @@ The recommended time is how much time you should spend on that task. If you find (If you're doing the internship, we'll start this one together at the start of the internship and is **not** a part of the pre-work) [Project](./Project/README.md) +# jay-chen-is-so-handsome From d6f2a85df6ff76b2cddd08e7c7d2b38ec29d8987 Mon Sep 17 00:00:00 2001 From: VincentHan12 Date: Sat, 15 Nov 2025 16:20:12 +1300 Subject: [PATCH 17/17] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 0d7ae94f1..c91dbeaa7 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The recommended time is how much time you should spend on that task. If you find - [x] 1. [Initial Set Up](/1-SetUp/README.md) (1.5hrs) - [x] 2. [Basics](/2-Basics/README.md) (7hrs) - [x] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs) -- [ ] 4. [Basic React](/4-React/README.md) (8hrs) +- [x] 4. [Basic React](/4-React/README.md) (8hrs) - [ ] 5. [Build your first react app](/5-MyFirstApp/README.md) (4hrs +) ## The next step @@ -29,4 +29,3 @@ The recommended time is how much time you should spend on that task. If you find (If you're doing the internship, we'll start this one together at the start of the internship and is **not** a part of the pre-work) [Project](./Project/README.md) -# jay-chen-is-so-handsome