Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| const everything = pair.split("="); | ||
| const key = decodeURIComponent(everything.shift().replace(/\+/g, " ")); | ||
| const value = decodeURIComponent(everything.join("=").replace(/\+/g, " ")); | ||
| if (queryParams[key]) { |
There was a problem hiding this comment.
What happens to the second a in a=&a=2 with this truthiness check?
To "like" or "dislike" this comment, please follow this link
| // E.g. invert({x : 10, y : 20}), target output: {"10": "x", "20": "y"} | ||
|
|
||
| function invert(obj) { | ||
| if (typeof obj !== "object") { |
There was a problem hiding this comment.
What happens when invert(null) reaches this guard, and which error does the function intend to report for invalid input?
To "like" or "dislike" this comment, please follow this link
| // Then it should throw Error("contains requires an object") | ||
| // (careful: typeof [] and typeof null are both "object") | ||
| test("contains on non-object returns contains requires an object", () => { | ||
| expect(() => contains(([1, 2, 3], "a"))).toThrow( |
There was a problem hiding this comment.
What single value does the comma expression inside contains(...) pass to the function?
To "like" or "dislike" this comment, please follow this link
|
|
||
| //On a new line it prints: | ||
| // title: "bruschetta", | ||
| // serves: 2, | ||
| // ingredients: "olive oil", "tomatoes", "salt", "pepper" | ||
|
|
||
| // Explain: on line 15 recipe is missing .ingredients. | ||
| // As a result it will print the whole property of recipe object. |
There was a problem hiding this comment.
These comments describe the pre-fix template, but the current template prints each ingredient on its own line and no longer prints the recipe object. The prediction and explanation should match the code now in the file.
To "like" or "dislike" this comment, please follow this link
|
|
||
| console.log(`My house number is ${address[0]}`); | ||
| console.log(`My house number is ${address["houseNumber"]}`); | ||
| // Predict: reference error will be returned. |
There was a problem hiding this comment.
What does address[0] produce in the original code, and what does this corrected lookup produce?
To "like" or "dislike" this comment, please follow this link
| console.log(value); | ||
| } | ||
|
|
||
| // Predict: it will return undefined. |
There was a problem hiding this comment.
What happens when you run this loop now, and does that match the prediction that it returns undefined?
To "like" or "dislike" this comment, please follow this link
|
The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look. |
Learners, PR Template
Self checklist
Task code
CYF-1083
Changelist
Debug, implement and interpret multiple code. Predict, explain and fix code. Implement functions and write test for different inputs