Giter Site home page Giter Site logo

m2-1-js--fundamentals-p1's Introduction

JavaScript Fundamentals - Part 1

Today we will be learning the fundamentals of JavaScript!

Setup

Look at SETUP.md for the instructions.

The Workshop

Each question is a JS file, except for the first 2. The question, including guidelines and hints, are also located each exercise file. You don't need to retype the code from the exercises, it is already available in the JS files.

Exercise 1

This is a series of theory questions for you to answer. Open exercise-1.md and answer in the file.

Exercise 2

This a series of code jumble questions. Answer directly in the exercise-2.md file.

Exercise 3 - Fix this program

It is supposed to print to the console the numbers 1, 2, 3, 4, 5.

for (let number = 2; number < 5; number++) {
  console.log(number);
}

Exercise 4 - Fix this program

It should output the squares of all numbers between 0 and 12

// eg:
// 0, 1, 4, 9, 16, ...

for (let number = 0; number < 12; number++) {
  console.log('the square of ', number, ' is ', square);
}

Exercise 5 - Fix this program

It should output all of the odd numbers between 1 and 25 (including 1 and 25).

for (let number = 0; number < 25; number++) {
  if (number % 2) {
    console.log(number);
  }
  console.log(number);
}

Exercise 6

This exercise contains 5 questios that all start with Write a loop that ...

Exercise 7

Write a loop that will output every hour of the day (0 to 23) and determine whether it is time to sleep, eat or train. Life in the army is regimented! These are the hours alloted to each activity.

  • Sleep between 22h and 5h
  • Eat at 7h, 13h and 18h
  • The rest of the time is spent training.

The output should look something like

It's 11h. Time to train!
It's 12h. Time to train!
It's 13h. Time to eat!

๐ŸŸก - Minimally complete workshop (75%) - ๐ŸŸก

Exercise 8

Write a program that will output the sum of all of the multiples of four between 0 and 5000

The number you should see in the console is 3127500

Exercise 9

Write a program that goes through every number between 1 and 100, and follows the following rules:

  • If the number is divisible by 3 (eg. 6), print "Fizz"
  • If the number is divisible by 5 (eg. 10), print "Buzz"
  • If the number is divisible by 3 AND 5 (eg. 15), print "FizzBuzz"
  • For all other numbers, print the number itself.

Exercise 10

Write a loop that makes seven calls to console.log to output the following triangle:

#
##
###
####
#####
######
#######

๐ŸŸข - Complete workshop (100%) - ๐ŸŸข

Exercise 11 - Stretch

Write a program that creates a string that represents an 8ร—8 grid, using newline characters to separate lines. At each position of the grid there is either an "_" or a "#" character. The characters should form a chessboard.

#_#_#_#_
_#_#_#_#
#_#_#_#_
_#_#_#_#
#_#_#_#_
_#_#_#_#
#_#_#_#_
_#_#_#_#

Exercise 12 - Stretch

Write a program that generates a list of all prime numbers between 1 and 200.

A prime number is a number that is ONLY divisible by 1 and itself.

  • 6 -> NOT prime (2 * 3)
  • 7 -> PRIME (can only be divided by 1 and 7, no other numbers)
  • 12 -> NOT prime (3 _ 4, 2 _ 6)
  • 37 -> PRIME ()

NOTE: 1 and 2 are both prime numbers.

EXPECTED OUTPUT: [1, 2, 3, 5, 7, 11, 13, ...]

Exercise 13 - Stretch

The Fibonacci sequence is a sequence of numbers where every value is the sum of the previous 2 values.

It looks like this:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...

Why?

13 + 21 = 34 8 + 13 =21 5 + 8 =13

See? Every number in the sequence is the result of adding the two numbers to the left. The sequence starts with "0, 1", and every number beyond that can be calculated by adding the previous 2 numbers.

Write a program which calculates the 50th number in the fibonacci sequence

(Correct answer: 12586269025) (The numbers get big quickly!)

m2-1-js--fundamentals-p1's People

Contributors

brokenwill avatar joshwcomeau avatar scottanthonymorin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.