Predict Integer Division
Predict Output Easy
Question
What does this code print?
Code
console.log(7 / 2);
console.log(Math.floor(7 / 2));
Hint
JavaScript division always returns a float; Math.floor rounds down.
Explanation
In JavaScript, 7 / 2 = 3.5 (JavaScript has only one number type, always floating point). Math.floor(3.5) rounds down to 3. The output is: 3.5 (first line) and 3 (second line). In Python, 7 / 2 = 3.5 and 7 // 2 = 3.
Related Resources
Related Lessons
- Numbers and Math
Learn about numbers and math operations.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.