“Nombres maths” Réponses codées

Nombres maths

parseFloat('98.6'); // 98.6
parseFloat('98.6 is the average normal temperature of the human body'); // 98.6
Cruel Cormorant

Nombres maths

const eightAndAHalf = 8.5;

Number.isInteger(eightAndAHalf); // false
Number.isInteger(Math.floor(eightAndAHalf)); // true
Cruel Cormorant

Nombres maths

// rounds a number down to the nearest integer
Math.floor(9.99); // 9

// rounds a number up to the nearest integer
Math.ceil(9.01); // 10

// rounds a number to the nearest integer
Math.round(9.51); // 10

// returns the largest of the numbers passed through it
Math.max(1, 2, 3, 4, 5); // 5

// returns the smallest of the numbers passed through it
Math.min(1, 2, 3, 4, 5); // 1

// returns a random number between 0 inclusive and 1 non-inclusive
Math.random(); // 0.31764219954126016
Cruel Cormorant

Nombres maths

parseInt("100", 10); // 100
parseInt("100", 2); // 4 (100 in the binary system)
Cruel Cormorant

Réponses similaires à “Nombres maths”

Questions similaires à “Nombres maths”

Plus de réponses similaires à “Nombres maths” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code