My Javascript code creation of the day – 01

Created this code from expanding on a exercise from Code with Mosh.

//Landscape mode or portrait mode check

 

let w = Math.floor(Math.random() * 800); //Creates the width dimensions.
let h = Math.floor(Math.random() * 800); //Creates the height dimensions.
let a2 = ‘This is landscape mode. ‘ + w + ‘ Pixels’ + ‘ by ‘ + h + ‘ Pixels’;
let b2 = ‘This is portait mode. ‘ + w + ‘ Pixels’ + ‘ by ‘ + h + ‘ Pixels’;
let c3 = “This has zero numbers.”

 

let thisnumber = isLandscape (w, h);

 

function isLandscape (width, height) {
if (width > height) return a2; //Checks to see if this is landscape dimensions.
else if (0 === width && 0 === height) return c3; //Checks to see if it has dimensions.
else return b2;
}

 

console.log(thisnumber);

You May Also Like