Goal: Practice gathering multiple pieces of information from corresponding sets of checkbox forms.
Similar to the site depicted in the previous lesson, create a website that prompts users to fill out a survey regarding which methods of transportation they've used to get to work in the past year. Include at least five options for users to select from.
Then, once you can successfully gather data from one question, include a second survey question asking users which methods of transportation they've used to travel to non-work or recreational activities. This second question should use a second set of checkboxes.
Next, create a personality quiz that contains several questions that use checkboxes to select answers. Each question should instruct users to "Check all that apply".
A factorial is an operator that multiplies a number by all of the positive integers less than that number. For example, 5! = 5 * 4 * 3 * 2 * 1 = 120.
By definition, 0! = 1.
Make a web page to compute factorials. Do it without recursion, and then try it with recursion if you're up for a challenge. (Look online for info on recursion.)
A palindrome is any word, phrase, number, or other sequence of characters which reads the same backward or forward. Create a web page to identify whether or not a word is a palindrome.
Bonus points: Make your code check a string of words. For example: "Hello olleH" is a palindrome by our definition.
You may want to browse some of the built-in Javascript functionality available for strings and arrays.
Given a number, write a method that returns all of the prime numbers less than that number.
This is a tricky problem, and I want you to use the Sieve of Eratosthenes to solve it. Here's how the Sieve of Eratosthenes works to find a number up to a given number
:
number
.prime
equal 2, the first prime number.prime
, remove all multiples of prime
from the list.prime
by 1.number
, all the remaining numbers in the list are primes.You also might find this video helpful in explaining the Sieve.
Now, implement this in JavaScript, using behavior examples to guide you. If you have time before class is over, make a website for a user to enter a number and return all of the prime numbers less than that number.
Lesson 16 of 16
Last updated more than 3 months ago.