Skip to content

Conversation

@VincentHan12
Copy link
Collaborator

@VincentHan12 VincentHan12 commented Sep 8, 2025

Summary by CodeRabbit

  • New Features

    • Added many utility helpers for objects, arrays, strings, numbers and data-structures (searching, filtering, zipping, type helpers).
    • Added array and matrix utilities for creation, insertion, replacement, deletion, and updates.
    • New React UI components: Dog, DogList, Subtitle, and Main now displays a list of dogs.
  • Documentation

    • Marked several kata exercises and initial setup items as completed in READMEs.
  • Chores

    • Updated editor save action configuration for linting.

@coderabbitai
Copy link

coderabbitai bot commented Sep 8, 2025

Walkthrough

Implements many previously-stubbed kata functions across multiple JS modules, adds new React components (Dog, DogList, Subtitle) with index re-exports, tweaks VS Code ESLint on-save setting, and updates README checkboxes. Several modules gain exports; no public-signature removals.

Changes

Cohort / File(s) Summary
Editor config
/.vscode/settings.json
Changed editor.codeActionsOnSave.eslint from boolean true to string "explicit" and reformatted the mapping to multi-line.
Objects & Arrays kata
/3-JSKata/1-objects-and-arrays/kata.js
Implemented many functions: getGreeting, ageOneYear, makeObject, getPropertyValue, addName, deleteProperty, returnErrorIfFalsy, getKeys, getValues, makeArrayOfItem, makeArrayOfItems, hasItem, getItemAtIndex, replaceItemAtIndex, insertItemAtIndex, deleteItemAtIndex, deleteItem, zipObject, unzipObject, findOneByProperty, findAll; updated module.exports.
Strings & Numbers utilities
/3-JSKata/2-strings-and-numbers/utilities.js
Implemented utilities: getType, isNumber, toNumber, isStringNumber, add, addStrings, addStringsOrNumbers, isEmail (regex), countIf (loop), filterStringsWithCommas, splitStringByCommas. Contains an incidental console.log and an implicit global in countIf.
Data structures — find / where / accessors
/3-JSKata/3-data-structures/find.js, .../where.js, .../getValue.js, .../getType.js, .../getPropTypes.js
find.js: implemented single-match search using first key of searchDetails (uses loose equality; searchKey undeclared). where.js: implemented multi-key filter returning matches. getValue.js, getType.js, getPropTypes.js: implemented simple accessors (return obj[key], typeof thing, and for...in types collection respectively).
Data structures — positions & matrix
/3-JSKata/3-data-structures/positions.js, .../matrix.js
Implemented getFirst, added/exported getLast; getMatrix(n) creates an n×n zero-filled matrix; updateMatrix(matrix, coords, value) updates cell and returns matrix.
Types — functions utilities
/3-JSKata/4-types/functions.js
Added functional utilities: callsFunction, callsProperty, filter, find, map; updated exports.
Types — primitives & getters
/3-JSKata/4-types/types.js
New module adding/exporting: getBoolean, getFunction, getNull, getNumber, getObject, getString.
Kata docs / root README
/3-JSKata/README.md, /README.md
Toggled several checklist items from unchecked to checked in both README files.
React — Dog, DogList, Subtitle, Main
/4-React/src/components/Dog/Dog.jsx, /4-React/src/components/Dog/index.js, /4-React/src/components/DogList/DogList.jsx, /4-React/src/components/DogList/index.js, /4-React/src/components/Subtitle/Subtitle.jsx, /4-React/src/components/Subtitle/index.js, /4-React/src/components/Main/Main.jsx
Added Dog, DogList, and Subtitle components and index re-exports; Main.jsx imports them, defines a hardcoded dogs array and renders Logo, Subtitle, and DogList.

Sequence Diagram(s)

sequenceDiagram
  participant Main as Main.jsx
  participant DogList as DogList
  participant Dog as Dog

  rect rgb(245,250,245)
  note over Main,DogList: Main composes DogList with hardcoded dogs
  Main->>DogList: render DogList(dogs)
  DogList->>Dog: render Dog(name, breed, superpower) [for each]
  Dog-->>DogList: DOM for single dog
  DogList-->>Main: rendered list
  end
Loading
sequenceDiagram
  participant Caller
  participant ObjectsArrays as 1-objects-and-arrays/kata.js
  participant DataStructures as 3-data-structures/*

  Caller->>ObjectsArrays: addName(obj, name)
  ObjectsArrays-->>Caller: newObj (spread copy)
  Caller->>ObjectsArrays: replaceItemAtIndex(arr, idx, item)
  ObjectsArrays-->>Caller: newArr (item replaced)
  Caller->>DataStructures: where(arr, {k:v,...})
  DataStructures-->>Caller: matches[]
  Caller->>DataStructures: find(arr, {k:v})
  DataStructures-->>Caller: firstMatch | undefined
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Attention points:

  • utilities.js: stray console.log and implicit global variable in countIf.
  • find.js: searchKey is undeclared (creates implicit global) and uses loose equality (==).
  • getPropTypes.js: uses for...in (may include inherited enumerable props).
  • getItemAtIndex (kata.js): returns Error() when value is falsy — confirm intended contract.
  • Insert/replace/delete array ops: verify immutability vs. in-place behavior (some use splice on copies).
  • React Dog: image filename derivation lowercases only first char — confirm correctness for breeds.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Completed third task' is vague and generic, providing no meaningful information about what was actually changed in the pull request. Replace with a specific title describing the main changes, such as 'Complete JavaScript kata exercises and add React dog list component' or 'Implement kata functions and create Dog/DogList React components'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vincenthan12-main

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 422bb7c and d6f2a85.

📒 Files selected for processing (1)
  • README.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[uncategorized] ~23-~23: Did you mean “JavaScript” (= programming language)?
Context: ...](/2-Basics/README.md) (7hrs) - [x] 3. Java Script Kata's (8hrs) - [...

(JAVA_SCRIPT)

🔇 Additional comments (1)
README.md (1)

1-31: Verify that the personal heading on line 32 has been removed.

A previous review flagged a critical issue: line 32 contained the personal heading "# jay-chen-is-so-handsome", which does not belong in a professional README and should be deleted. The provided file snippet only shows through line 31, so I cannot confirm whether this has been addressed.

Please verify that this personal heading has been removed from the file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 13

🧹 Nitpick comments (5)
3-JSKata/README.md (1)

85-88: Tiny copy edit: pluralize “Objects”.

Consider “Objects and arrays” for correctness and consistency.

- - [x] [Object and arrays](./1-objects-and-arrays/README.md) (2hrs)
+ - [x] [Objects and arrays](./1-objects-and-arrays/README.md) (2hrs)
README.md (1)

21-23: Copy edit: standardize “JavaScript Katas”.

Current text has spacing and an apostrophe. Suggest the common form below.

- - [x] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs)
+ - [x] 3. [JavaScript Katas](/3-JSKata/README.md) (8hrs)
3-JSKata/3-data-structures/positions.js (1)

1-7: LGTM; optionally guard empty/non-array inputs.

If you want safer helpers, return undefined for non-arrays or empty arrays.

-function getFirst(arr) {
-  return arr[0]
-}
+function getFirst(arr) {
+  return Array.isArray(arr) ? arr[0] : undefined
+}
 
-function getLast(arr) {
-  return arr[arr.length - 1]
-}
+function getLast(arr) {
+  return Array.isArray(arr) && arr.length ? arr[arr.length - 1] : undefined
+}
3-JSKata/3-data-structures/matrix.js (1)

1-8: Validate n and simplify construction

Guard invalid n and use Array.from for clarity/perf.

-function getMatrix(n) {
-  let newMatrix = []
-  for (let i = 0; i < n; i++) {
-    const row = Array(n).fill(0)
-    newMatrix.push(row)
-  }
-  return newMatrix
-}
+function getMatrix(n) {
+  if (!Number.isInteger(n) || n < 0) throw new TypeError('n must be a non-negative integer')
+  return Array.from({ length: n }, () => Array(n).fill(0))
+}
3-JSKata/1-objects-and-arrays/kata.js (1)

141-149: Prefer strict equality and for...of

Avoid coercion and use direct element iteration.

 function deleteItem(arr, item) {
-  let newArr = []
-  for (const i in arr) {
-    if (arr[i] != item) {
-      newArr.push(arr[i])
-    }
-  }
-  return newArr
+  const newArr = []
+  for (const el of arr) {
+    if (el !== item) newArr.push(el)
+  }
+  return newArr
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f181481 and b09e2f7.

📒 Files selected for processing (14)
  • .vscode/settings.json (1 hunks)
  • 3-JSKata/1-objects-and-arrays/kata.js (2 hunks)
  • 3-JSKata/2-strings-and-numbers/utilities.js (1 hunks)
  • 3-JSKata/3-data-structures/find.js (1 hunks)
  • 3-JSKata/3-data-structures/getPropTypes.js (1 hunks)
  • 3-JSKata/3-data-structures/getType.js (1 hunks)
  • 3-JSKata/3-data-structures/getValue.js (1 hunks)
  • 3-JSKata/3-data-structures/matrix.js (1 hunks)
  • 3-JSKata/3-data-structures/positions.js (1 hunks)
  • 3-JSKata/3-data-structures/where.js (1 hunks)
  • 3-JSKata/4-types/functions.js (1 hunks)
  • 3-JSKata/4-types/types.js (1 hunks)
  • 3-JSKata/README.md (1 hunks)
  • README.md (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (9)
3-JSKata/2-strings-and-numbers/utilities.js (12)
3-JSKata/3-data-structures/3-tests/getType.test.js (1)
  • getType (1-1)
3-JSKata/2-strings-and-numbers/2-tests/getType.test.js (1)
  • getType (1-1)
3-JSKata/2-strings-and-numbers/2-tests/isNumber.test.js (1)
  • isNumber (1-1)
3-JSKata/2-strings-and-numbers/2-tests/toNumber.test.js (1)
  • toNumber (1-1)
3-JSKata/2-strings-and-numbers/2-tests/isStringNumber.test.js (1)
  • isStringNumber (1-1)
3-JSKata/2-strings-and-numbers/2-tests/add.test.js (1)
  • add (1-1)
3-JSKata/2-strings-and-numbers/2-tests/addStrings.test.js (1)
  • addStrings (1-1)
3-JSKata/2-strings-and-numbers/2-tests/addStringsOrNumbers.test.js (1)
  • addStringsOrNumbers (1-1)
3-JSKata/2-strings-and-numbers/2-tests/isEmail.test.js (1)
  • isEmail (1-1)
3-JSKata/2-strings-and-numbers/2-tests/countIf.test.js (1)
  • countIf (1-1)
3-JSKata/2-strings-and-numbers/2-tests/filterStringsWithCommas.test.js (1)
  • filterStringsWithCommas (1-1)
3-JSKata/2-strings-and-numbers/2-tests/splitStringByCommas.test.js (2)
  • filterStringsWithCommas (2-2)
  • splitStringByCommas (1-1)
3-JSKata/3-data-structures/getType.js (2)
3-JSKata/3-data-structures/3-tests/getType.test.js (1)
  • getType (1-1)
3-JSKata/2-strings-and-numbers/2-tests/getType.test.js (1)
  • getType (1-1)
3-JSKata/3-data-structures/matrix.js (1)
3-JSKata/3-data-structures/3-tests/matrix.test.js (1)
  • matrix (1-1)
3-JSKata/3-data-structures/getValue.js (1)
3-JSKata/3-data-structures/3-tests/getValue.test.js (1)
  • getValue (1-1)
3-JSKata/3-data-structures/getPropTypes.js (1)
3-JSKata/3-data-structures/3-tests/getPropTypes.test.js (1)
  • getPropTypes (1-1)
3-JSKata/3-data-structures/find.js (2)
3-JSKata/3-data-structures/3-tests/find.test.js (1)
  • find (2-2)
3-JSKata/3-data-structures/where.js (1)
  • searchKey (3-3)
3-JSKata/4-types/functions.js (1)
3-JSKata/3-data-structures/matrix.js (1)
  • i (3-3)
3-JSKata/3-data-structures/where.js (1)
3-JSKata/3-data-structures/3-tests/where.test.js (1)
  • where (2-2)
3-JSKata/1-objects-and-arrays/kata.js (2)
3-JSKata/1-objects-and-arrays/1-tests/addName.test.js (2)
  • name (5-5)
  • obj (6-8)
3-JSKata/1-objects-and-arrays/1-tests/hasItem.test.js (2)
  • arr (5-5)
  • arr (16-16)
🔇 Additional comments (4)
.vscode/settings.json (1)

8-10: Confirm intended ESLint behavior on save.

"explicit" disables auto-fix on save and only runs when you trigger “Fix all”. If you intended auto-fix on save, set it to true instead.

-    "source.fixAll.eslint": "explicit"
+    "source.fixAll.eslint": true
3-JSKata/3-data-structures/getValue.js (1)

1-3: LGTM.

Simple and correct for the kata.

3-JSKata/3-data-structures/getType.js (1)

1-3: LGTM with a note on edge cases.

typeof null === 'object' and arrays return 'object'. If tests ever need special handling, consider detecting those explicitly.

3-JSKata/4-types/types.js (1)

1-34: LGTM

Simple getters match intent; no issues spotted.

Comment on lines +13 to +22
function ageOneYear(obj) {
console.log(obj)
let newObj = {
...obj,
age: obj['age'] + 1,
}
console.log(newObj)

return newObj
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove debug logging and streamline

console.log calls are noisy in library code. Simplify return.

-function ageOneYear(obj) {
-  console.log(obj)
-  let newObj = {
-    ...obj,
-    age: obj['age'] + 1,
-  }
-  console.log(newObj)
-
-  return newObj
-}
+function ageOneYear(obj) {
+  return { ...obj, age: obj.age + 1 }
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function ageOneYear(obj) {
console.log(obj)
let newObj = {
...obj,
age: obj['age'] + 1,
}
console.log(newObj)
return newObj
}
function ageOneYear(obj) {
return { ...obj, age: obj.age + 1 }
}
🤖 Prompt for AI Agents
In 3-JSKata/1-objects-and-arrays/kata.js around lines 13 to 22, remove the two
console.log debugging lines and simplify the function to return the updated
object directly; replace the current creation of newObj and intermediate logs by
returning a new object that spreads obj and sets age to obj.age + 1 (no logging,
no unused variables).

Comment on lines +107 to +113
function getItemAtIndex(arr, idx) {
if (arr[idx]) {
return arr[idx]
} else {
return Error()
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Index existence check is incorrect

arr[idx] fails for falsy values (0, '', false). Check bounds instead.

 function getItemAtIndex(arr, idx) {
-  if (arr[idx]) {
-    return arr[idx]
-  } else {
-    return Error()
-  }
+  if (Number.isInteger(idx) && idx >= 0 && idx < arr.length) return arr[idx]
+  return Error()
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function getItemAtIndex(arr, idx) {
if (arr[idx]) {
return arr[idx]
} else {
return Error()
}
}
function getItemAtIndex(arr, idx) {
if (Number.isInteger(idx) && idx >= 0 && idx < arr.length) return arr[idx]
return Error()
}
🤖 Prompt for AI Agents
In 3-JSKata/1-objects-and-arrays/kata.js around lines 107 to 113, the current
existence check uses arr[idx] which rejects valid falsy values (0, '', false);
replace it with an explicit bounds check (e.g. idx >= 0 && idx < arr.length) so
valid falsy entries are returned, and return the item when in-bounds otherwise
return a new Error (or appropriate error value/message).

Comment on lines +182 to +192
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
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Implicit global in for-of loop

obj is undeclared; declare it.

 function findAll(arr, search) {
-  let newArr = []
-  let key = Object.keys(search)[0]
-  let value = search[key]
-  for (obj of arr) {
+  let newArr = []
+  let key = Object.keys(search)[0]
+  let value = search[key]
+  for (const obj of arr) {
     if (obj[key] == value) {
       newArr.push(obj)
     }
   }
   return newArr
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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
}
function findAll(arr, search) {
let newArr = []
let key = Object.keys(search)[0]
let value = search[key]
for (const obj of arr) {
if (obj[key] == value) {
newArr.push(obj)
}
}
return newArr
}
🤖 Prompt for AI Agents
In 3-JSKata/1-objects-and-arrays/kata.js around lines 182 to 192, the for-of
loop uses an undeclared variable obj causing an implicit global; declare the
loop variable (e.g., change to "for (const obj of arr)" or "for (let obj of
arr)") to avoid polluting global scope and ensure proper block scoping.

Comment on lines +13 to +15
function isStringNumber(str) {
return typeof str == 'string' && !isNaN(str)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Tighten numeric string check

Current logic treats whitespace-only strings as numbers. Use trim + Number.isFinite.

-function isStringNumber(str) {
-  return typeof str == 'string' && !isNaN(str)
-}
+function isStringNumber(str) {
+  return typeof str === 'string' && str.trim() !== '' && Number.isFinite(Number(str))
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function isStringNumber(str) {
return typeof str == 'string' && !isNaN(str)
}
function isStringNumber(str) {
return typeof str === 'string'
&& str.trim() !== ''
&& Number.isFinite(Number(str))
}
🤖 Prompt for AI Agents
In 3-JSKata/2-strings-and-numbers/utilities.js around lines 13-15, the
isStringNumber implementation treats whitespace-only strings as numbers; change
the check to first ensure str is a string, then call str.trim() and if the
trimmed string is non-empty convert it with Number(...) and use
Number.isFinite(...) to verify it's a finite numeric value (i.e., return typeof
str === 'string' && str.trim() !== '' && Number.isFinite(Number(str.trim()))).

Comment on lines +33 to +37
function isEmail(str) {
console.log
const emailRegex = /.+@.+\..+/
return emailRegex.test(str)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove stray console.log and anchor regex

The bare console.log is a no-op and may fail linting. Anchor the regex to reduce false positives.

-function isEmail(str) {
-  console.log
-  const emailRegex = /.+@.+\..+/
-  return emailRegex.test(str)
-}
+function isEmail(str) {
+  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
+  return emailRegex.test(str)
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function isEmail(str) {
console.log
const emailRegex = /.+@.+\..+/
return emailRegex.test(str)
}
function isEmail(str) {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
return emailRegex.test(str)
}
🤖 Prompt for AI Agents
In 3-JSKata/2-strings-and-numbers/utilities.js around lines 33 to 37, remove the
stray bare console.log call and anchor the email regex to avoid false positives;
replace the regex /.+@.+\..+/ with an anchored pattern like /^.+@.+\..+$/ (or a
tighter RFC-compliant pattern if desired) and keep the function returning
emailRegex.test(str).

Comment on lines +10 to +15
function updateMatrix(matrix, coords, value) {
const x = coords[0]
const y = coords[1]
matrix[x][y] = value
return matrix
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Bounds/input checks for coords

Access without validation can throw or corrupt state. Add type/bounds checks.

-function updateMatrix(matrix, coords, value) {
-  const x = coords[0]
-  const y = coords[1]
-  matrix[x][y] = value
-  return matrix
-}
+function updateMatrix(matrix, coords, value) {
+  const [x, y] = coords
+  if (!Array.isArray(matrix) || !Array.isArray(matrix[x])) throw new TypeError('matrix must be a 2D array')
+  if (!Number.isInteger(x) || !Number.isInteger(y) || x < 0 || y < 0 || x >= matrix.length || y >= matrix[x].length) {
+    throw new RangeError('coords out of bounds')
+  }
+  matrix[x][y] = value
+  return matrix
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function updateMatrix(matrix, coords, value) {
const x = coords[0]
const y = coords[1]
matrix[x][y] = value
return matrix
}
function updateMatrix(matrix, coords, value) {
const [x, y] = coords
if (!Array.isArray(matrix) || !Array.isArray(matrix[x])) throw new TypeError('matrix must be a 2D array')
if (
!Number.isInteger(x) ||
!Number.isInteger(y) ||
x < 0 ||
y < 0 ||
x >= matrix.length ||
y >= matrix[x].length
) {
throw new RangeError('coords out of bounds')
}
matrix[x][y] = value
return matrix
}
🤖 Prompt for AI Agents
In 3-JSKata/3-data-structures/matrix.js around lines 10 to 15, the updateMatrix
function writes to matrix[x][y] without validating coords or types; add input
and bounds checks: verify matrix is an array of arrays, coords is an array/tuple
of two finite integers, and value is acceptable for your domain; check 0 <= x <
matrix.length and 0 <= y < matrix[x].length (or handle ragged rows) and throw a
clear TypeError/RangeError if validations fail; only perform the assignment and
return the matrix after all checks pass.

Comment on lines +1 to +20
function where(arr, searchDetails) {
let newArr = []
const searchKey = Object.keys(searchDetails)

for (const obj of arr) {
let match = true

for (const i in searchKey) {
if (obj[searchKey[i]] != searchDetails[searchKey[i]]) {
match = false
}
}

if (match) {
newArr.push(obj)
}
}
console.log(newArr)
return newArr
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove console.log and simplify matching; prefer strict equality.

Unconditional logging is noisy. The loop can be simplified and short-circuited; use === to avoid coercion.

 function where(arr, searchDetails) {
-  let newArr = []
-  const searchKey = Object.keys(searchDetails)
-
-  for (const obj of arr) {
-    let match = true
-
-    for (const i in searchKey) {
-      if (obj[searchKey[i]] != searchDetails[searchKey[i]]) {
-        match = false
-      }
-    }
-
-    if (match) {
-      newArr.push(obj)
-    }
-  }
-  console.log(newArr)
-  return newArr
+  const keys = Object.keys(searchDetails)
+  return arr.filter((obj) => keys.every((k) => obj && obj[k] === searchDetails[k]))
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function where(arr, searchDetails) {
let newArr = []
const searchKey = Object.keys(searchDetails)
for (const obj of arr) {
let match = true
for (const i in searchKey) {
if (obj[searchKey[i]] != searchDetails[searchKey[i]]) {
match = false
}
}
if (match) {
newArr.push(obj)
}
}
console.log(newArr)
return newArr
}
function where(arr, searchDetails) {
const keys = Object.keys(searchDetails)
return arr.filter((obj) => keys.every((k) => obj && obj[k] === searchDetails[k]))
}
🤖 Prompt for AI Agents
In 3-JSKata/3-data-structures/where.js around lines 1-20, remove the console.log
and simplify/short-circuit the matching logic while using strict equality:
compute the searchKeys with Object.keys(searchDetails), iterate over them with a
for...of (or use Array.prototype.every) and break/short-circuit as soon as a
non-match is found, comparing values with === instead of !=; push matching
objects to newArr (or return arr.filter(...) directly) and return the result
without any console output.

Comment on lines +9 to +17
function filter(arr, func) {
const elements = []
for (i in arr) {
if (func(arr[i])) {
elements.push(arr[i])
}
}
return elements
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid for...in on arrays and implicit globals

for...in iterates keys (and inherited) and i is undeclared; use for...of.

 function filter(arr, func) {
   const elements = []
-  for (i in arr) {
-    if (func(arr[i])) {
-      elements.push(arr[i])
-    }
-  }
+  for (const el of arr) {
+    if (func(el)) elements.push(el)
+  }
   return elements
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function filter(arr, func) {
const elements = []
for (i in arr) {
if (func(arr[i])) {
elements.push(arr[i])
}
}
return elements
}
function filter(arr, func) {
const elements = []
for (const el of arr) {
if (func(el)) elements.push(el)
}
return elements
}
🤖 Prompt for AI Agents
In 3-JSKata/4-types/functions.js lines 9-17, the function uses for...in and an
undeclared i which iterates inherited keys and creates an implicit global;
replace it with a proper array iteration (e.g., for (const item of arr) { if
(func(item)) elements.push(item); }) or use arr.forEach/arr.filter, and ensure
any loop variable is declared with let/const to avoid globals.

Comment on lines +19 to +25
function find(arr, func) {
for (i in arr) {
if (func(arr[i])) {
return arr[i]
}
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Same issue in find

Switch to for...of to avoid global i and prototype keys.

 function find(arr, func) {
-  for (i in arr) {
-    if (func(arr[i])) {
-      return arr[i]
-    }
-  }
+  for (const el of arr) {
+    if (func(el)) return el
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function find(arr, func) {
for (i in arr) {
if (func(arr[i])) {
return arr[i]
}
}
}
function find(arr, func) {
for (const el of arr) {
if (func(el)) return el
}
}
🤖 Prompt for AI Agents
In 3-JSKata/4-types/functions.js around lines 19 to 25, the current
implementation uses "for (i in arr)" which leaks a global i and iterates
prototype keys; replace it with a for...of loop such as "for (const item of
arr)" and call func(item), returning item when true; also ensure the function
returns undefined (or null) explicitly if no element matches.

Comment on lines +27 to +33
function map(arr, func) {
const elements = []
for (i in arr) {
elements.push(func(arr[i]))
}
return elements
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Same issue in map

Use for...of and local variable.

 function map(arr, func) {
   const elements = []
-  for (i in arr) {
-    elements.push(func(arr[i]))
-  }
+  for (const el of arr) {
+    elements.push(func(el))
+  }
   return elements
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function map(arr, func) {
const elements = []
for (i in arr) {
elements.push(func(arr[i]))
}
return elements
}
function map(arr, func) {
const elements = []
for (const el of arr) {
elements.push(func(el))
}
return elements
}
🤖 Prompt for AI Agents
In 3-JSKata/4-types/functions.js around lines 27-33, the map implementation uses
a for-in loop and an undeclared loop variable which can iterate over inherited
properties and leak a global; change it to use a for...of loop with a local loop
variable (e.g., for (const item of arr)) and call func(item) when pushing into
the elements array so iteration is safe and variables are properly scoped.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
4-React/src/components/Subtitle/Subtitle.jsx (1)

1-7: Simple and functional implementation.

The component correctly renders the subtitle text. Consider destructuring props for cleaner code:

-export function Subtitle(props) {
+export function Subtitle({ text }) {
   return (
     <h2>
-      <span className="subtitle">{props.text}</span>
+      <span className="subtitle">{text}</span>
     </h2>
   )
 }
4-React/src/components/DogList/DogList.jsx (1)

3-11: Consider prop destructuring for cleaner code.

The component logic is correct. For improved readability, consider destructuring the dogs prop:

-export function DogList(props) {
+export function DogList({ dogs }) {
   return (
     <>
-      {props.dogs.map((dog, index) => (
+      {dogs.map((dog, index) => (
         <Dog key={dog.name} name={dog.name} breed={dog.breed} superpower={dog.superpower} />
       ))}
     </>
   )
 }
4-React/src/components/Dog/Dog.jsx (1)

1-19: Well-structured component with correct image path logic.

The breed-to-image-path transformation is implemented correctly, and the component layout is clean and semantic.

Consider destructuring props for improved readability:

-export function Dog(props) {
-  const imageBreed = props.breed.charAt(0).toLowerCase() + props.breed.slice(1)
+export function Dog({ name, breed, superpower }) {
+  const imageBreed = breed.charAt(0).toLowerCase() + breed.slice(1)
   return (
     <div className="dog-wrapper">
       <div className="dog">
         <img
           src={`/images/${imageBreed}.png`}
-          alt={props.breed}
+          alt={breed}
           className="dog-image"
         />
         <div className="dog-name-plate">
-          <span className="dog-name">{props.name}</span>
-          <span className="dog-breed">{props.breed}</span>
+          <span className="dog-name">{name}</span>
+          <span className="dog-breed">{breed}</span>
         </div>
-        <span className="dog-superpower">{props.superpower}</span>
+        <span className="dog-superpower">{superpower}</span>
       </div>
     </div>
   )
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b09e2f7 and 4f566f1.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • 4-React/src/components/Dog/Dog.jsx (1 hunks)
  • 4-React/src/components/Dog/index.js (1 hunks)
  • 4-React/src/components/DogList/DogList.jsx (1 hunks)
  • 4-React/src/components/DogList/index.js (1 hunks)
  • 4-React/src/components/Main/Main.jsx (1 hunks)
  • 4-React/src/components/Subtitle/Subtitle.jsx (1 hunks)
  • 4-React/src/components/Subtitle/index.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • 4-React/src/components/Subtitle/index.js
🧰 Additional context used
🧬 Code graph analysis (2)
4-React/src/components/DogList/DogList.jsx (1)
4-React/src/components/Dog/Dog.jsx (1)
  • Dog (1-19)
4-React/src/components/Main/Main.jsx (3)
4-React/src/components/Logo/Logo.jsx (1)
  • Logo (1-3)
4-React/src/components/Subtitle/Subtitle.jsx (1)
  • Subtitle (1-7)
4-React/src/components/DogList/DogList.jsx (1)
  • DogList (3-11)
🪛 Biome (2.1.2)
4-React/src/components/DogList/DogList.jsx

[error] 7-7: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🔇 Additional comments (3)
4-React/src/components/Dog/index.js (1)

1-1: LGTM!

Clean barrel export following React conventions.

4-React/src/components/Main/Main.jsx (1)

1-31: LGTM!

The component composition is well-structured with clear separation of concerns. The dogs data array and component rendering logic are implemented correctly.

4-React/src/components/DogList/index.js (1)

1-1: LGTM!

Clean barrel export following React conventions.

Comment on lines +6 to +8
{props.dogs.map((dog) => (
<Dog name={dog.name} breed={dog.breed} superpower={dog.superpower} />
))}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Missing key prop in mapped Dog components.

React requires a unique key prop for each element in a list to efficiently track changes and prevent rendering issues. Without keys, React may re-render items incorrectly when the list changes.

Apply this diff to add the key prop:

-      {props.dogs.map((dog) => (
-        <Dog name={dog.name} breed={dog.breed} superpower={dog.superpower} />
+      {props.dogs.map((dog, index) => (
+        <Dog key={dog.name} name={dog.name} breed={dog.breed} superpower={dog.superpower} />
       ))}

Note: Using dog.name as the key assumes each dog has a unique name. If names might not be unique, consider using a unique ID field or index as a fallback (though index is less optimal for dynamic lists).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{props.dogs.map((dog) => (
<Dog name={dog.name} breed={dog.breed} superpower={dog.superpower} />
))}
{props.dogs.map((dog, index) => (
<Dog key={dog.name} name={dog.name} breed={dog.breed} superpower={dog.superpower} />
))}
🧰 Tools
🪛 Biome (2.1.2)

[error] 7-7: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🤖 Prompt for AI Agents
In 4-React/src/components/DogList/DogList.jsx around lines 6 to 8, the mapped
<Dog> elements are missing a unique key prop; add a key prop to the rendered Dog
component (e.g., key={dog.name}) and if dog.name may not be unique use a unique
id field like dog.id or, as a last resort, key={index} by including the map
index in the callback signature; ensure the key is placed on the top-level
element returned by the map.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4f566f1 and 422bb7c.

📒 Files selected for processing (1)
  • README.md (2 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[uncategorized] ~23-~23: Did you mean “JavaScript” (= programming language)?
Context: ...](/2-Basics/README.md) (7hrs) - [x] 3. Java Script Kata's (8hrs) - [...

(JAVA_SCRIPT)

- [ ] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs)
- [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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Standardize "JavaScript" spelling.

The standard spelling is "JavaScript" (one word, capital J), not "Java Script".

Apply this diff to correct the spelling:

- [x] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs)
+ [x] 3. [JavaScript Kata's](/3-JSKata/README.md) (8hrs)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [x] 3. [Java Script Kata's](/3-JSKata/README.md) (8hrs)
- [x] 3. [JavaScript Kata's](/3-JSKata/README.md) (8hrs)
🧰 Tools
🪛 LanguageTool

[uncategorized] ~23-~23: Did you mean “JavaScript” (= programming language)?
Context: ...](/2-Basics/README.md) (7hrs) - [x] 3. Java Script Kata's (8hrs) - [...

(JAVA_SCRIPT)

🤖 Prompt for AI Agents
In README.md around line 23, replace the incorrect "Java Script" with the
standardized single-word spelling "JavaScript" so the line reads "[x] 3.
[JavaScript Kata's](/3-JSKata/README.md) (8hrs)"; apply that exact spelling
change in the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants