Question: In JavaScript, write out solution code for a function titled MyFunction(start, end) . This function will take in two arguments, referenced as start and end.

In JavaScript, write out solution code for a function titled MyFunction(start, end). This function will take in two arguments, referenced as start and end. The output of the function should returning an array containing both numbers and/or strings, based on certain conditions and as the operation increases one-by-one from start to end, certain values will be inserted into the output array. Include both start and end. No need HTML format.

When incrementing from start to end, evaluate the current number in the iteration according to these conditions:

Here are the conditions:

  • For multiples of three, insert "StringThree" instead of the number into the output array
  • For multiples of five, insert "StringFive" instead of the number into the output array
  • For numbers which are multiples of both three and five, insert "String" into the output array
  • For numbers which are neither a multiple of three nor a multiple of five, insert the number into the output array

Example of the code:

function MyFunction(start, end) {

// Insert code here;

}

MyFunction(1, 15);

Output: [1, 2, "StringThree", 4, "StringFive", "StringThree", 7, 8, "StringThree", "StringFive", 11, "StringThree", 13, 14, "String"]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!