0Pricing
Javascript for Kids · Lesson

Random Answers

Pick a reply.

The Magic 8-Ball! 🎱

Hi fortune teller! 🌟 Have you seen a Magic 8-Ball? You ask a question and it gives a surprise answer! 🎱

Today we make one in code! First step: picking a random answer! 🎲

A List of Answers 📋

First we need a list of replies! 📋

We store many answers in an array (a list in square brackets). 🪄

let answers = ['Yes!', 'No way!', 'Maybe...'];
console.log(answers);

All lessons in this course

  1. Asking a Question
  2. Random Answers
  3. Revealing the Fortune
  4. Add More Answers
← Back to Javascript for Kids