Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ex 2-2, 2-3, 2-4, 2-5
  • Loading branch information
annagabain committed Aug 12, 2019
commit bad3e60c312b69ec85cf7f8acde3eaafb3c37c5d
5 changes: 5 additions & 0 deletions Week3/homework/MY-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@
</head>
<body>
<source src="MY-step2-1.js"></source>
<source src="MY-step2-2-Func_with_4_Arg.js"></source>
<source src="MY-step2-4-Some-practice-with-objects.js"></source>
<source src="MY-step2-5-Nest-for-loops.js"></source>


</body>
</html>
2 changes: 1 addition & 1 deletion Week3/homework/MY-step2-1-Hello_I_am_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function foo(func) {
// What to do here?
// Replace this comment and the next line with your code
return ('Hi, I am AaaaT, who are you?');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same problem again. This function should take a function and invoke/call it. Not return anything.

console.log(func);
//console.log(func);
}

function bar() {
Expand Down
49 changes: 49 additions & 0 deletions Week3/homework/MY-step2-2-Func_with_4_Arg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';

/*2.2 You must write a function that takes 4 arguments.

A start value
An end value
A callback to call if the number is divisible by 3
A callback to use if the number is divisible by 5
The function should first generate an array containing values from start value to end value (inclusive).

Then the function should take the newly created array and iterate over it, and calling the first callback if the array value is divisible by 3.

The function should call the second callback if the array value is divisible by 5.

Both functions should be called if the array value is divisible by both 3 and 5. */

function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) {
const numbers = [];
// Replace this comment and the next line with your code
for (let i = startIndex; i <= stopIndex; i++) {
numbers.push(i);
//A callback to call if the number is divisible by 3
if (i % 3 === 0) {
threeCallback(i);
}
//A callback to use if the number is divisible by 5
if (i % 5 === 0) {
fiveCallback(i);
}
}
}

threeFive()


function sayThree(number) {
// Replace this comment and the next line with your code
console.log(number, 'value is divisible by 3');
}

function sayFive(number) {
// Replace this comment and the next line with your code
console.log(number, 'value is divisible by 5');
}

threeFive(10, 15, sayThree, sayFive);

// Do not change or remove anything below this line
module.exports = threeFive;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

function Dog() {
// add your code here
this.name = "Woofy Boy",
this.color = "Brown",
this.numLegs = 4;

}

const hound = new Dog();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
'use strict';
//'use strict';

function multiplyAll(arr) {
// eslint-disable-next-line
let product = 1;

// Replace this comment and the next line with your code
for(let i=0; i < arr.length; i++){
for (let j=0; j < arr[i].length; j++){
product = product * arr[i][j];
}
}
console.log(arr, product);

return product;
}

const result = multiplyAll([[1, 2], [3, 4], [5, 6]]);
console.log(result); // 720
const result = multiplyAll([[3, 4], [5, 6], [7, 8]]);
console.log(result); // 20160

// Do not change or remove anything below this line
module.exports = multiplyAll;

23 changes: 0 additions & 23 deletions Week3/homework/step2-2.js

This file was deleted.