Question

Write 3 JavaScript programs: The first should compute the sum of 2 given integers. The second...

Write 3 JavaScript programs:

The first should compute the sum of 2 given integers. The second should multiply the 2 integers. The third should triple the sum of the 2 integers.

Homework Answers

Answer #1

function sum(a,b){
    return a+b;
}
i = parseInt(prompt("Enter first number: "))
j = parseInt(prompt("Enter second number: "))
console.log("Sum = "+sum(i,j));

function mult(a,b){
    return a*b;
}
i = parseInt(prompt("Enter first number: "))
j = parseInt(prompt("Enter second number: "))
console.log("Product = "+mult(i,j));

function tripleSum(a,b){
    return 3*(a+b);
}
i = parseInt(prompt("Enter first number: "))
j = parseInt(prompt("Enter second number: "))
console.log("Sum = "+tripleSum(i,j));
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Given an array of integers return the sum of the values stored in the first and...
Given an array of integers return the sum of the values stored in the first and last index of the array. The array will have at least 2 elements in it --------------------------------------- public class Class1 { public static int endSum(int[] values) {     //Enter code here } }
The sum of three numbers is−2. The sum of twice the first number, 3 times the...
The sum of three numbers is−2. The sum of twice the first number, 3 times the second number, and 4 times the third number is−15. The difference between 5 times the first number and the second number is 28. Find the three numbers.(Set up variable(s), set up equation(s) and then solve the equation(s) to answer the question.)
3. Write a JavaScript code that print 3 color (yellow, black, red). You should create an...
3. Write a JavaScript code that print 3 color (yellow, black, red). You should create an array that has all the color then use a loop to print the array.
In C++ Please, Write a program that (1) prompts for two integers, (2) prints out their...
In C++ Please, Write a program that (1) prompts for two integers, (2) prints out their sum, (3) prints out the first divided by the second, and (4) prints out the natural log of the first number raised to the power of the second number. #include <iostream> #include <iomanip> using namespace std; int main() { <your answer goes here> return 0; }
Write Python expressions corresponding to the following statements: The sum of the first five positive integers...
Write Python expressions corresponding to the following statements: The sum of the first five positive integers The average age of Sara (age 23), Mark (age 19), and Fatima (age 31) The number of times 73 goes into 403 The remainder when 403 is divided by 73 2 to the 10th power The absolute value of the difference between Sara’s height (54 inches) and Mark’s height (57 inches) The lowest price among the following prices: $34.99, $29.95, and $3
Write in Racket Language Write a recursive Racket function "sum" that takes two integers as parameters,...
Write in Racket Language Write a recursive Racket function "sum" that takes two integers as parameters, each greater or equal to zero, and evaluates to their sum. In this problem, you must use the built-in functions "add1" and "sub1" and may not use the built-in functions "+" or "-". For example, (sum 2 3) should evaluate to 5. Note: (add1 5) evaluates to 6 and (sub1 4) evaluates to 3. Hint: like you saw in the "append" lecture, treat one...
Linux 2)   Write a bash script which when executed, expects two integers, say n1 and n2....
Linux 2)   Write a bash script which when executed, expects two integers, say n1 and n2. If the first argument, n1, is greater than the second argument, n2, the script calls a function (written within the script) and passes to the function n1 and n2 to compute the sum from n1 to n2. This function returns the sum which the script prints. If n1 is not greater than n2, the script calls the same function and passes the n1 and...
Python: Write a function called sum_odd that takes two parameters, then calculates and returns the sum...
Python: Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use at least...
11. Write a program to compute the sum of the series 12 + 22 + 32....
11. Write a program to compute the sum of the series 12 + 22 + 32. . . ., such that the sum is doesnot exceed 1000. The program should display how many terms are used in the sum. {3 marks} matlab only 1 to power of 2 , 2 to the power of 2 , 3 to the power of 3 , not 12 + 22 + 32
For Java programming code: Write methods to add and multiply 1) Two integers 2) Two decimals...
For Java programming code: Write methods to add and multiply 1) Two integers 2) Two decimals 3) One integer and one decimal
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT