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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
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
Estimated delivery fee Deliver to Chile

Standard delivery 10 - 13 business days

$19.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

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 : 9781785287176
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Chile

Standard delivery 10 - 13 business days

$19.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

Product Details

Publication date : Jan 30, 2016
Length: 188 pages
Edition : 1st
Language : English
ISBN-13 : 9781785287176
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

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela