Javascript

use let to assign variables

exports.handler = async (event) => {
    let firstname = 'John';
    let lastname = 'Iacovacci';
    var response = firstname + ' ' + lastname
    return response;
};

The + sign allows for strings to be concatenated together


rules for variables

Variables names  can only start with letter, $ or _

can not start with a number.

variable names can not be reserved key words

let fahrenheit


exports.handler = async (event) => {
   
let fahrenheit = 50;
let celsius = (fahrenheit - 32) * 5 / 9;
let kelvin = (fahrenheit + 459.67) * 5 / 9;
let response = 'When it is ' + fahrenheit + ' Fahrenheit ' + ' The temparaturepature in Celsius is ' + celsius + ' The temparature in kelvin is '  + kelvin;

    return response;
};

Boolean data types

true or false

comparison operators

 === - equality operator
 !== - no equal opeartor
 < - less than operator
 > - greater than opeartor
 <= - less than or equal to operator
 >= - greater than or equal to opeartor

let temp = 32
let isFreezing = temp <= 32

console.log(isFreezing)

// Challenge area

// Create age set to your age
let age = 65
// Calculate is child - if they are 7 or under
let isChild = age <= 7
// Calculate is senior - if they are 65 or older
let isSenior = age >= 65
// Print is child value
console.log(isChild)
// Print is senior value
console.log(isSenior)

No comments:

Post a Comment

To All, If you are working in starter accounts please move the work into the classroom account so I can review. For the previous ...