-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Hi Kenan, here is my feedback on your homework.
It would be better if you started your file with 'use strict' to catch any undeclared variables.
Step 4.1
OK
Step 4.2
In the assignment it was asked to create an array with numbers between a start value and an end value passed as parameters to your function. Instead, you function uses a fixed array where only the first value and the last value is set through a parameter.
The for loop implementation is correct.
It would have been better if you passed the current number to your dividableOnThree and dividableOnFive functions so that you could console.log '9 is divisible by 3' rather than 'Yes, it is divisibly by 3' (what is divisible by 3?)
Step 4.3
Perhaps you were a bit confused what was asked here. When you have a string "abc" the result of repeating it 3 times should be a new string "abcabcabc", not printing it three times on the console. So your function should return a new string based on the arguments supplied.
The implementations with a do and do-while loop seem to be missing.
Step 4.4
OK
Step 4.5
Your multiplyAll function should not console.log anything. It should compute the product of all elements in the two-dimensional array.
Your second for loop is using the incorrect length. And you are not computing the product but multiplying each number by 2 (why 2?) and then console logging it.
To make your code work, I had to make the following changes (I commented out the incorrect lines):
function multiplyAll(arr) {
let product = 1;
for (let index = 0; index < arr.length; index++) {
// for (let i = 0; i < arr.length; i++) {
for (let i = 0; i < arr[index].length; i++) {
// console.log(arr[index][i] * 2);
product *= arr[index][i];
}
};
return product;
}
// multiplyAll([[1, 2], [3, 4], [5, 6, 7]]);
console.log(multiplyAll([[1, 2], [3, 4], [5, 6, 7]]));This produces the correct result of 5040.
Step 4.7
Your conclusions are correct.
Step 5
You are supposed to write a function that returns a new function (using a closure). See my the solution I posted in slack. Your code doesn't run: TypeError: addSix is not a function
Bonus
If I comment out the code that doesn't run then the bonus runs ok with the right results. Nice solution with using Set and Array.from()