JavaScript Math Methods Quiz

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the output range of the Math.random() method?

  • 0.1 to 1.0
  • 0 to 1.0
  • 0 to 0.99 (correct)
  • 1.0 to 2.0

What would be the result of Math.ceil(1.5)?

  • 1
  • 3
  • 1.5
  • 2 (correct)

If you multiply the result of Math.random() by 10, what is the potential range of output values?

  • 1 to 10
  • 0.1 to 9.9
  • 0 to 10
  • 0 to 9.9 (correct)

What does the Math.ceil(2.99) return?

<p>3 (D)</p> Signup and view all the answers

Which of the following statements about Math.ceil() is correct?

<p>It rounds up decimal numbers to the nearest integer. (A)</p> Signup and view all the answers

Flashcards

Math.random() output

Generates decimal numbers between 0 (inclusive) and 1 (exclusive).

Math.random() range

The default range is 0 to 0.99; can be extended by multiplying by a number.

Math.ceil() function

Rounds a decimal number up to the nearest whole number.

Math.ceil(0.0001)

Returns 1.

Signup and view all the flashcards

Math.ceil(1.5)

Returns 2.

Signup and view all the flashcards

Study Notes

Math.random() Method

  • Generates a decimal number between 0 (inclusive) and 1 (exclusive).
  • The result is a floating-point number.
  • Can be stored in a variable for later use.

Expanding the Range

  • Multiplying the result by a number (e.g., 10) increases the output range.

Math.ceil() Method

  • Rounds a decimal number up to the nearest integer.
  • Always rounds up, regardless of the decimal portion.
  • Example: Math.ceil(0.0001) returns 1.
  • Example: Math.ceil(1.5) returns 2.
  • Example: Math.ceil(2.99) returns 3.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

More Like This

JavaScript Editing Techniques
3 questions
Basic JavaScript Functions Quiz
6 questions

Basic JavaScript Functions Quiz

SustainableAntigorite1088 avatar
SustainableAntigorite1088
JavaScript Class Definition
12 questions
Math Constants and Methods Quiz
5 questions
Use Quizgecko on...
Browser
Browser