You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.0 KiB
JavaScript

console.log('hello world');
let num1 = 25;
let num2 = "5";
console.log("The result of num1 + num2 should be 30.");
console.log("Actual Result:");
console.log(num1 + 5);
let num3 = 156;
let num4 = "44";
console.log("The result of num3 + num4 should be 200.");
console.log("Actual Result:");
console.log(num3 + 44);
let num5 = "seventeen";
let num6 = 10;
console.log("The result of num5 - num6 should be 7.");
console.log("Actual Result:");
console.log(17-num6);
console.log('There are 5265000 minutes in a year.');
/*
2. Given the values below, calculate the total number of minutes in a year and save the result in a variable called resultMinutes.
*/
let minutesHour = 60;
let hoursDay = 24;
let daysWeek = 7;
let weeksMonth = 4;
let monthsYear = 12;
let daysYear = 365;
const resultMinutes = 5265000
console.log('There are'+resultMinutes+'minutes in a year.');
/*
3. Given the values below, calculate and convert the temperature from celsius to fahrenheit and save the result in a variable called resultFahrenheit.
*/
let tempCelsius = 132;
let resultFahrenheit = (tempCelsius * 9/5) + 32;
console.log('132 degrees Celcius when converted to Farenheit is ' + resultFahrenheit);
/*
4a. Given the values below, identify if the values of the following variable are divisible by 8.
-Use a modulo operator to identify the divisibility of the number to 8.
-Save the result of the operation in a variable called remainder1.
-Log the value of the remainder in the console.
-Using the strict equality operator, check if the remainder is equal to 0.
-Save the returned value of the comparison in a variable called isDivisibleBy8
-Log a message in the console if num7 is divisible by 8.
-Log the value of isDivisibleBy8 in the console.
*/
let num7 = 165;
const remainder1 = (num7 % 8);
console.log('the remainder of 165 divided by 8 is :' + remainder1);
//Log the value of the remainder in the console.
console.log("Is num7 divisible by 8?");
const isDivisibleBy8 = (remainder1 === 0);
console.log(isDivisibleBy8);
//Log the value of isDivisibleBy8 in the console.
/*
4b. Given the values below, identify if the values of the following variable are divisible by 4.
-Use a modulo operator to identify the divisibility of the number to 4.
-Save the result of the operation in a variable called remainder2.
-Log the value of the remainder in the console.
-Using the strict equality operator, check if the remainder is equal to 0.
-Save the returned value of the comparison in a variable called isDivisibleBy4
-Log a message in the console if num8 is divisible by 4.
-Log the value of isDivisibleBy4 in the console.
*/
let num8 = 348;
const remainder2 = (num8 % 4);
console.log('The remainder of 348 divided by 4 :' + remainder2);
//Log the value of the remainder in the console.
console.log("Is num8 divisible by 4?");
const isDivisibleBy4 = (remainder2 === 0);
console.log(isDivisibleBy4);
//Log the value of isDivisibleBy4 in the console.
//Do not modify
//For exporting to test.js
//Note: Do not change any variable and function names. All variables and functions to be checked are listed in the exports.
try{
module.exports = {
num1: typeof num1 !== 'undefined' ? num1 : null,
num2: typeof num2 !== 'undefined' ? num2 : null,
num3: typeof num3 !== 'undefined' ? num3 : null,
num4: typeof num4 !== 'undefined' ? num4 : null,
num5: typeof num5 !== 'undefined' ? num5 : null,
num6: typeof num6 !== 'undefined' ? num6 : null,
resultMinutes: typeof resultMinutes !== 'undefined' ? resultMinutes : null,
resultFahrenheit: typeof resultFahrenheit !== 'undefined' ? resultFahrenheit : null,
remainder1: typeof remainder1 !== 'undefined' ? remainder1 : null,
remainder2: typeof remainder2 !== 'undefined' ? remainder2 : null,
isDivisibleBy4: typeof isDivisibleBy4 !== 'undefined' ? isDivisibleBy4 : null,
isDivisibleBy8: typeof isDivisibleBy8 !== 'undefined' ? isDivisibleBy8 : null
}
} catch(err){
}