Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
JavaScript Projects for Kids
JavaScript Projects for Kids

JavaScript Projects for Kids: Gear up for a roller-coaster ride into the world of JavaScript and programming with this easy-to-follow, fun, and entertaining project-based guide

eBook
$9.99 $22.99
Paperback
$27.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

JavaScript Projects for Kids

Chapter 1. Exploring JavaScript in the Console

Before we start talking about lines of codes, objects, variables, and so on, we need to know what JavaScript is. JavaScript is a programming language that is used to add interactivities to the web pages and build web applications. Static websites are not very popular these days, therefore, we use JavaScript to make our websites interactive.

Some people also call it a scripting language as it is an easy language and does not require compilers like other languages. JavaScript was not designed as a general purpose programming language, it was designed to manipulate web pages. You can write a desktop application using JavaScript. JavaScript can also access your machine's hardware. You can try making a desktop application with a software development kit (SDK) such as PhoneGap for mobile or the Microsoft app SDK for desktop. The JavaScript codes are interpreted on web pages and then run by a browser. Any modern Internet browser, for example Firefox, Safari, Google Chrome, UC Browser, Opera, and so on, supports JavaScript.

Note

A compiler is a computer program that processes codes and turns them to machine language. Making a website interactive means adding features that are controlled by the users to the website. For example, online registration forms, online calculator, and so on. The Static website has fixed objects and contents and it displays the same information to all the visitors.

Basically, JavaScript is included on an HTML page or written on a separate file that has a .js extension. If you know nothing about HTML, don't worry as you will learn about it in Chapter 3, Introducing HTML and CSS. So, where can you use JavaScript?

The answer is simple, you can do the following:

  • You can create an active user interface.
  • You can control web browsers.
  • You can validate user inputs (if they are typed wrong).
  • You can create custom web pages that can pop up on the browser, holding information or images.
  • You can create dynamic pages without Common Gateway Interface (CGI). CGI is used by the web servers to process a browser's information.

Note

The thing that you should remember is JavaScript is not Java, the programming language developed by Sun Microsystem.

Throughout this book, we will use Google Chrome as the default browser and Atom as the text editor.

If you do not have these two software already installed on your computer, it is necessary to download and install them.

We will use the Atom text editor as it is a cross-platform editor, has a built-in package manager, does smart autocompletion, and has a lot of other advantages.

Installing Google Chrome

To install Google Chrome go to http://www.google.com/chrome and click Download now, as shown in the following screenshot:

Installing Google Chrome

Then press the Accept and Install button, as shown in the following screenshot:

Installing Google Chrome

The installation will be completed depending on your network speed and machine's hardware configurations.

Note

Uncheck Set Google Chrome as my default browser if you don't want to use Google Chrome as your default browser.

Installing Atom

To install the Atom text editor, follow the https://atom.io/ link and press Download Windows Installer, as shown in the following screenshot:

Installing Atom

A file called AtomSetup.exe will start downloading.

Click on the AtomSetup.exe file to get started with installing Atom.

Tip

Make sure that you give the administrative rights while installing it for better performance.

Atom will launch automatically after the installation is completed.

If you are on another platform, use the Other platforms link:

  • If you are a Mac user, go to the https://github.com/atom/atom/releases/latest link and download the atom-X.X.X-full.nupkg file, where X.X.X is the version number of Atom. Install it by double-clicking on the file.
  • If you are an Ubuntu user, you can follow the https://github.com/atom/atom/releases/latest link and download the atom-amd64.deb file. After downloading it, launch your Terminal in the same folder, where you placed the file after downloading it. Then, write the following code:
    sudo dpkg --install atom-amd64.deb
    

    You may need the administrative password to install it. After the installation is complete, you can run Atom from the Terminal by typing Atom and pressing Enter.

Chrome Developer Tools

Let's take a look at the Chrome Developer Tools that are used for JavaScript, specially the console. Since Google Chrome is downloaded and installed on your machine, open the Google Chrome browser, go to the menu (on the right-hand top corner), hover on More tools and select Developer tools, as shown in the following screenshot:

Chrome Developer Tools

You will see the following tools:

  • Elements
  • Network
  • Sources
  • Timeline
  • Profiles
  • Resources
  • Audits
  • Console

Our first program

Now, let's check whether JavaScript works on your machine.

From the tools, select Console. If you cannot find Console, click on the >> symbol, as follows:

Our first program

Once your console is open, type the following code and hit Enter on your keyboard:

document.write("Hello World");

If you can see the output on the left-hand side panel as shown in the following, then you have successfully configured JavaScript on your browser:

Our first program

The output that you will see is as follows:

Hello World

Congratulations!

Note

Downloading the example code

You can download the example code files for all the Packt books that you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register in order to have the files e-mailed to you directly.

If you cannot see the text, check your code or install Google Chrome with administrative rights.

You can also click on the gear button of your console. Check whether Disable JavaScript is unchecked:

Our first program

You can also debug your JavaScript codes using this tool.

If you type anything wrong; consider that you forgot the inverted commas of the Hello World string, you will get the following errors:

Our first program

To speed up writing your codes, you may learn some keyboard shortcuts for both console and Atom text editor.

Here are few keyboard shortcuts for console:

  • Ctrl + L: Clear console
  • Tab: Autocomplete common prefix
  • Right arrow: Accept suggestion
  • Ctrl + U: Clear console prompt
  • Up/Down: Next/previous line
  • Enter: Execute command

Here are few keyboard shortcuts for Atom text editor:

  • Ctrl + B: Browse list of open files
  • Ctrl +Alt + R: Reload Atom
  • Ctrl +Shift + L: Change syntax highlighting
  • Alt +Shift + S: Show available code snippets
  • Ctrl +Shift + M: Markdown preview
  • Ctrl +Alt + I: Toggle Developer Tools
  • Ctrl + N: New file
  • Ctrl +Shift + N: New Window
  • Ctrl + P: Open file (type the name to perform a search)
  • Ctrl + O: Open file
  • Ctrl +Shift + O: Open folder
  • Ctrl + S: Save
  • Ctrl +Shift + S: Save as
  • Ctrl + W: Close tab
  • Ctrl +Shift + W: Close window
  • Ctrl + G: Go to line
  • Ctrl + L: Select line
  • Ctrl +Shift + D: Duplicate line
  • Ctrl +Shift + K: Delete line
  • Ctrl + Up/Down: Move line up/down
  • Ctrl + /: Toggle comment line
  • Ctrl + Enter: New line below
  • Ctrl + [/]: Indent/unindent selected lines
  • Ctrl + J: Join lines
  • Ctrl + Alt + .: Complete bracket
  • Ctrl + M: Go to matching bracket
  • Ctrl + Alt + M: Select code inside matching brackets
  • Ctrl + Alt + /: Fold/unfold code
  • Ctrl + Alt + F: Fold selected code
  • Ctrl + Alt + [/]: Fold/unfold all code
  • Ctrl + F: Find in current file
  • Ctrl + Shift + F: Find in project
  • F3: Find next
  • Shift + F3: Find previous
  • Ctrl + Enter: Replace all
  • Ctrl + Alt + /: Use Regex in search
  • Ctrl + Shift + =/-: Increase/decrease text size
  • Ctrl + 0 (zero): Reset text size
  • F11: Toggle fullscreen

Why do we use Chrome Developer Tools?

The following points the use of Chrome Developer Tools:

  • Easy to see the errors
  • Easy to edit/debug codes using the line numbers
  • Real-time output (No need to refresh the page)

Why do we use Atom as the text editor?

The following points the use of Atom as the text editor:

  • Zero-compromise combination of hackability and usability
  • An open source text editor
  • Every Atom window is essentially a locally-rendered web page

Exercise

To enhance your knowledge of JavaScript, write a program that will print your name.

Summary

In this chapter, we saw how to download Google Chrome and Atom, and install them.

You learned how to write your first code using Chrome Developer Tools (Console). You have also learned a few keyboard shortcuts for Chrome Developer Tools and Atom text editor.

You also learned what JavaScript is, why learning JavaScript is important, and how JavaScript is different from other languages.

We can now jump in the world of JavaScript.

Your journey begins from Chapter 2, Solving Problems Using JavaScript.

Left arrow icon Right arrow icon

Key benefits

  • Get to know the concepts of HTML and CSS to work with JavaScript
  • Explore the concepts of object-oriented programming
  • Follow this step-by-step guide on the fundamentals of JavaScript programming

Description

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.

Who is this book for?

If you've never written code before or you are completely new to the world of web programming, then this book is the right choice for you. This book is for kids of age 10 years and above and parents who are completely new to the world of programming and want to get introduced to programming.

What you will learn

  • Learn how to work with Google Developer tools to iterate, debug and profile your code
  • Develop a Battleship game using the basic concepts of HTML and CSS
  • Get to know the fundamentals of JavaScript programming
  • Create our own version of Pac Man game.
  • Discover the vital concepts of object-oriented programming

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 30, 2016
Length: 188 pages
Edition : 1st
Language : English
ISBN-13 : 9781783988495
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jan 30, 2016
Length: 188 pages
Edition : 1st
Language : English
ISBN-13 : 9781783988495
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 93.97
Raspberry Pi Projects for Kids (Second Edition)
$26.99
Python Projects for Kids
$38.99
JavaScript Projects for Kids
$27.99
Total $ 93.97 Stars icon
Banner background image

Table of Contents

11 Chapters
1. Exploring JavaScript in the Console Chevron down icon Chevron up icon
2. Solving Problems Using JavaScript Chevron down icon Chevron up icon
3. Introducing HTML and CSS Chevron down icon Chevron up icon
4. Diving a Bit Deeper Chevron down icon Chevron up icon
5. Ahoy! Sailing into Battle Chevron down icon Chevron up icon
6. Exploring the Benefits of jQuery Chevron down icon Chevron up icon
7. Introducing the Canvas Chevron down icon Chevron up icon
8. Building Rat-man! Chevron down icon Chevron up icon
9. Tidying up Your Code Using OOP Chevron down icon Chevron up icon
10. Possibilities Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5
(2 Ratings)
5 star 50%
4 star 0%
3 star 0%
2 star 50%
1 star 0%
Towaha Apr 07, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Easy for not only kids but for new learners. Recommended.
Amazon Verified review Amazon
G. A. Patino Jul 11, 2016
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
A common complaint about many textbooks is that they start explaining everything very simply, but after a few chapters the level of complexity suddenly ramps up and the book leaves many readers behind. This book is a perfect example of that. I got it because, despite knowing some other programming languages, I wanted to learn JavaScript. The initial 4 chapters were great and provided a good introduction to the language, along with the key concepts of HTML and CSS. However, in chapter 5 the author basically posted the code for a version of the game Battleship stating what each portion of the code would do but not explaining how the commands listed achieved so. It might be possible for somebody with prior programming experience to intuit what the new commands and functions presented do, but if this is a book for kids I wonder how easy it is for them to achieve this if it is their first foray into programming. I was also looking for a good teaching text, not a demonstration of the things you can do with the language. Chapter 6 and 7 again do a decent job of introducing JQuery and the HTML Canvas, but chapters 8 and 9 are again just code listings (although chapter 9 offers a basic description of object-oriented programming concepts) for two other games without any explanations of the new functions or the Angular framework that are used. The first chapters of the book demonstrate the author's ability to explain concepts clearly and in a friendly manner, I hope that in the next edition of the book he keeps that spirit in all of the book's chapters.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.