Exercise: Translate

You will be translating formulas into code in this exercise.

Task

A mathematician reached out to us for help. He needs help translating his equations in JavaScript. Every time he tries to do it, the code gives the wrong output. Your task is to help him translate the problems into JavaScript. Good luck!

Problem statements

In this exercise, you convert a series of word problems or equations into JavaScript code. Keep in mind the precedence and associative rules while coding.

The mathematician has a series of questions for us. Solve them one by one.

Q1. Double the sum

The problem is as follows:

For 2 variables, x and y, find twice the value of the sum of the two variables.

The variables x and y are defined for us. Store the value in the ans variable.

Get hands-on with 1200+ tech skills courses.