Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assignments/create_object/CreateObject.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Instructions
```bash
Example:
Input - ["firstName", "Yash", "lastName": "Goyal"]
Output - { firstName: "Yash", lastName: "Goyal" }
Output - { firstName: "Yash", lastName: "Goral" }
```

Run ```npm run test:file create_object``` to test your code
8 changes: 7 additions & 1 deletion assignments/create_object/create_object.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
function CreateObject(arr) {
// Write your code here
var res = {};
for (var i = 0; i < arr.length; i = i + 2) {
res[arr[i]] = arr[i + 1]
}
return res

}

module.exports = CreateObject;
module.exports = CreateObject;
21 changes: 21 additions & 0 deletions assignments/play_with_array/play_with_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ function getEven(arr) {

Write you code below
*/
var res = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i] % 2 == 0) {
res.push(arr[i])
}
}
return res;


}

Expand All @@ -18,6 +26,12 @@ function multiplyByN(arr, n) {
Output: [3,9,13,165]
Write you code below
*/
var res = [];
for (var i = 0; i < arr.length; i++) {
res.push(arr[i] * n)
}
return res

}

function removeNthElement(arr, n) {
Expand All @@ -28,6 +42,13 @@ function removeNthElement(arr, n) {
Output: [1,3,4,7]
Write you code below
*/
var res = []
for (var i = 0; i < arr.length; i++) {
if (i != n) {
res.push(arr[i])
}
}
return res
}

module.exports = {
Expand Down