Answered step by step
Verified Expert Solution
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:
QStart with an array called inputtable. The array should have numbers between
and
QUse inputtable from Q to create the following:
a Set of multiples of between and Name it fiveTable, print the contents to the console
b Set of multiples of between and 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
QGet and then print the odd multiples of between and
QGet and then print the sum of even multiples of between and
Example: find the multiples and then sum them:
QUse currying to rewrite the function below:
function cylindervolumer h
var volume r r h;
return volume;
a Use r and h to call your curried function.
b Reuse the function from part a but use h
c Reuse the function from part a but use h
QUse 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 cellelement You can use the console to output your results.
Note: you MUST call makeTag at least once but may NOT call it more than times.
makeTag functionbeginTag endTag
return functiontextcontent
return beginTag textcontent endTag;
Example output for # Note that the tag is optional. Please do not use this data, but
substitute your own values for the contents of the cells.
Firstname
Lastname
Age
Jill
Smith
Eve
Jackson
QDo the generic version of questions and meaning the target
multiple must not be hard coded; hint: we studied closures and currying. This means you should be able to use the same code to handle multiple scenarios, for example: first odd multiples of and then even multiples of still in the range to Your code should allow the grader to combine a chosen multiple along with the choice of odd even without writing any code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started