ProjectBlog: Try an Hour of Code with BSD Online

Blog: Try an Hour of Code with BSD Online

Written by Eva Yeung of BSD Education

For this year’s Hour of Code, challenge your students with a special BSD Hour of Code project: Build your own AI Smart Car! In this fun project, you and your students have the opportunity to develop the main AI (artificial intelligence) logic for a self-driving car, using JavaScript programming.

The project begins with a parked car that, through the project, students need to make reach a destination target without crashing or getting a ticket. The objective is to gradually build up the logic of the car so that it can automatically start, shift to drive, gain enough speed, not go over the speed limit, stop at red lights and take correct turns. Students will be challenged to apply their Computational Thinking skills to deconstruct the obstacles at hand and come up with a set of algorithmic instructions in JavaScript to navigate their car to the target destination.

Find the project solutions below


Key JavaScript concepts used:

  • Variables
  • Conditional statements
  • Functions

Before starting the project, engage your class by initiating a discussion by asking:

  1. What do you already know about AI — Artificial Intelligence?
  2. Can you predict how robots will change our world?
  3. What are the advantages and disadvantages of self-driving cars?
  4. Which parts of school do you think robots will take over first? What are the benefits and risks?
  5. What does AI mean for jobs in the future?
  6. Can robots be creative? (Watch “Can robots be creative?” by Gil Weinberg on TedEd)

If you want to take this project further, you can learn more about AI by using these video resources:

Project Solutions

Step 1:

Objective: get the car started:

Solution: engineOn(); drive();

Step 2:

Objective: get the car to speed up:

Solution: + accelerate();

Step 3:

Objective: avoid going over the speed limit:

Solution: if speed >= limit cruise();

Step 4:

Objective: stop at red light and go at green light.

Step 5:

Objective: turn right at next road with junction

Solution: if atConjunction(): turn(nextDirection)

Interested in learning more about Coding? Email Eva at or read more articles here.

Source: Artificial Intelligence on Medium

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top

Display your work in a bold & confident manner. Sometimes it’s easy for your creativity to stand out from the crowd.