Write code in the javascript files according to the following descriptions.
future-age.js
Create a variable called age
and set its value to your age. Now, write another line of code that logs out a sentence telling you how old you will be in five years.
adder.js
Create two variables, num1
and num2
. Store any numbers in the variables.
Below this, add num1
and num2
together and store the result in a new variable (name it whatever you want).
Finlly, log out num1
, num2
, and sum
in a human readable sentence (i.e.: “8 and 5 add to 13”).
greeter.js
Create a variable name
and store your name in it.
Below this, write a line of code that displays some greeting to that name (i.e.: “Hello Barry!”)
remainder.js
Create two variables that each store a positive number (name them anything you want, any positive numbers will do).
Log out how the remainder that is left over when the first number is divided by the second number (i.e.: “the remainder of 7 divided by 3 is 1”)
distance.js
Create four variables, x1
, y1
, x2
, and y2
and store numbers in each of them.
Calculate the distance between coordinates (x1, y1) and (x2, y2). Log this distance out to the user in a human readable sentence.
The distance formula along with an example can be found below.
Remember, squaring a number or an expression just means to multiply that number or expression by itself. We can use the following syntax operations to square the number 5.
let a = 5;
let aSquared = a*a;
let b = 5;
let bSquared = b**2;
//both aSquared and bSquared will result to 25
quadratic.js
Create three variables, a
, b
, and c
.
Set them to any numbers you please as long as:
b²
is greater than or equal to 4 × a × c
Now use the quadratic formula (oh no) to calculate two value of two new variables, x1
and x2
.
Note: you’ll need to do the formula twice. For x1
, use a + in place of the ± symbol. For x2
, use a -.