Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Functional Programming using JavaScript You are encouraged to use map ( ) / filter ( ) / reduce ( ) which are available in the

Functional Programming using JavaScript
You are encouraged to use map()/ filter()/ reduce() which are available in the JavaScript array datatype and your program should not ask for any user input
Write an explanation of your code for each item below using comments.
Do NOT use a form of a for loop anywhere, including iterators. This is meant to be
a functional exercise, so your code is expected to not have side effects.
Instructions:
Q1.Start with an array called inputtable. The array should have numbers between
1 and 10.
Q2.Use inputtable from Q1 to create the following: -
a. Set of multiples of 5 between 1 and 51. Name it fiveTable, print the contents to the console
b. Set of multiples of 13 between 1 and 131. Name it thirteenTable, print the contents to the console
c. Set of squares of the numbers in inputtable. Name it squaresTable, print the contents to the console
Q3.Get (and then print) the odd multiples of 5 between 1 and 100.5,15,...
Q4.Get (and then print) the sum of even multiples of 7 between 1 and 100.
Example: find the multiples and then sum them: 14+28+...
Q5.Use currying to rewrite the function below:
function cylinder_volume(r, h){
var volume =3.14* r * r * h;
return volume;
}
a. Use r =5 and h =10 to call your curried function.
b. Reuse the function from part a but use h =17
c. Reuse the function from part a but use h =11-
Q6.Use the following code (insert it into your code) to take advantage of closures to wrap content with
HTML tags, specifically show an HTML table consisting of a table row that has at least
one table cell/element. You can use the console to output your results.
Note: you MUST call makeTag() at least once but may NOT call it more than 4 times.
makeTag = function(beginTag, endTag){
return function(textcontent){
return beginTag +textcontent +endTag;
}
}
Example output for #6. Note that the

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

What is the purpose of a costbenefit analysis?

Answered: 1 week ago