Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem #2 Modify the below code to print the numbers that have a remainder of 2

ID: 3699563 • Letter: P

Question

Problem #2 

Modify the below code to print the numbers that have a remainder of 2 when divided by 3 for the number 0 - 50. Sample code below from Chapter 5 of Eloquent JavaScript Textbook. 

 

function unless(test, then) {

if (!test) then();

}

function repeat(times, body) {

for (var i = 0; i < times; i++) body(i);

}

repeat(3, function(n) {

unless(n % 2, function() {

console.log(n, "is even");

});

});

 

Problem #3

Find the people from the ancestry data set (textbook) who are didn't live past their 40th birthday & who passed away after 1800. Downloadancestry.js.

Tip: Use the function filter() shown in Chapter 5 Eloquent JavaScript Textbook.

Explanation / Answer

function unless(test,then){

if(!test) then();

}

function repeat(time,body) {

for (var i=0; i=50; i++) body(i)

}

repeat(3,function(n){

unless(n %2,function(){

console.log(n,"is even");

});

});

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote