Answer to Question #176161 in HTML/JavaScript Web Application for mahidhar

Question #176161

Series of Operations

Given an array

  1. myArray of numbers, write a JS program to perform the following steps and log the result. Multiply each value with 9.
  2. Subtract 20 from each value.
  3. Multiply each value with 7.
  4. Log the values of the resulting array separated by a space.

Input

  • The input will be a single line containing an array myArray

Output

  • The output should be a single line with values separated by a space

Constraints

  • Each value in the array must be a number

Sample Input

[ 12, 2, 2, 4, 1 ]

Sample Output

616 -14 -14 112 -77




1
Expert's answer
2021-03-31T23:45:21-0400
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SO</title>
<script language="javascript" type="text/javascript">
    window.onload = function () {
        var arrayValuesString = prompt("Enter the numbers using comma", "");
        if (arrayValuesString != "") {
            var values = arrayValuesString.split(",");
            for (var i = 0; i < values.length; ++i) {
                values[i] *= 9;
            }
            for (var i = 0; i < values.length; ++i) {
                values[i] -= 20;
            }
            for (var i = 0; i < values.length; ++i) {
                values[i] *= 7;
            }
            console.log("[" + values.join(",") + "]\n")
        }
    }
    </script> 
</head>
<body>
	 
</body>
</html>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS