JavaScript Numbers and Dates - Exercise 1
It checks whether a value is a finite number without coercing other types.
Number.isFinite(42);
Use Number or a suitable parsing method.
const total = Number('19.5');
NaN represents a value that is not a valid number.
const result = Number('not a number');
console.log(Number.isNaN(result));
Math.floor returns the greatest integer less than or equal to the value.
Math.floor(4.9);
Math.random returns a value greater than or equal to zero and less than one.
const randomValue = Math.random();
It returns the current time as milliseconds since January 1, 1970 UTC.
const timestamp = Date.now();
Pass the string to the Date constructor.
const launchDate = new Date('2026-09-23T12:00:00Z');
Call getFullYear on the Date instance.
const year = launchDate.getFullYear();
Local Date methods use the environment's timezone, while UTC methods use UTC.
date.getHours();
date.getUTCHours();
Use toISOString for a UTC ISO 8601 representation.
const formatted = new Date().toISOString();