Book Image

JavaScript Projects for Kids

By : Syed Omar Faruk Towaha
Book Image

JavaScript Projects for Kids

By: Syed Omar Faruk Towaha

Overview of this book

JavaScript is the most widely-used programming language for web development and that's not all! It has evolved over the years and is now being implemented in an array of environments from websites to robotics. Learning JavaScript will help you see the broader picture of web development. This book will take your imagination to new heights by teaching you how to work with JavaScript from scratch. It will introduce you to HTML and CSS to enhance the appearance of your applications. You’ll then use your skills to build on a cool Battleship game! From there, the book will introduce you to jQuery and show you how you can manipulate the DOM. You’ll get to play with some cool stuff using Canvas and will learn how to make use of Canvas to build a game on the lines of Pacman, only a whole lot cooler! Finally, it will show you a few tricks with OOP to make your code clean and will end with a few road maps on areas you can explore further.
Table of Contents (17 chapters)
JavaScript Projects for Kids
About the Author
About the Reviewer

JavaScript methods

In the previous chapters, you learned how to print something using document.write(). Now, you will learn something more.

We will check the methods on both console and HTML document, as follows:

  • To show an alert or a pop-up box using JavaScript, we use the following method:

    alert("Hello World");

    Type this on the console and press Enter, you will see a pop-up box saying Hello World:

    You can write your code to show a pop-up box similar to the following on an HTML document:

        <script type="text/javascript">
          alert("Hello World");

    The output will be as follows:

  • If you want to take information from users, you need to use a prompt box to do this. Consider the following for example:

    • You want to take input of the username and print it on the main web page.

    • You can do this using the window.prompt() method.

    • The structure of window.prompt...