lesin / js-beginners

Le Wagon workshop 'JS for beginners'

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaScript for Beginners

  1. Tools
  2. Exercise 1
  3. Exercise 2
  4. Exercise 3
  5. Exercise 4

Tools

Exercise 1

Concatenate/Interpolate two strings

Use concatenation to join two strings together.

Use interpolation to embed JavaScript expressions inside a string (ES6).

HINT: Create a variable and store a string value inside it. Then embed this variable inside a string using interpolation (template literals syntax).

Use JS Bin ➡️ https://jsbin.com/?js,console. Write your code at the left, then press the run button to see the result.

Exercise 2

Filter names starting with a "B"

Define an Array of names (strings) and store it in a variable.

Use one of the discussed loop techniques to iterate over the Array and select names which starts with B.

Inside the loop, use an if condition and compare the first character of each name with the letter B.

HINT: You may need to define second array to store the matching results. You can use console.log() to see the what is stored inside your variables.

Use JS Bin ➡️ https://jsbin.com/?js,console. Write your code at the left, then press the run button to see the result.

Exercise 3

Filter names starting with "B" or "C" or any other letter

Let's refactor the previous exercise and use a function (use any type of function you'd like).

The function takes two parameters: one represents a list of names and the other represents the first letter to filter with.

Once you've created the function, call it with two arguments: a list of names (Array) and a letter (String).

HINT: Inside your function, don't forget to return the result.

Use JS Bin ➡️ https://jsbin.com/?js,console. Write your code at the left, then press the run button to see the result.

Exercise 4

Mark all checkboxes as 'checked' on some web page with checkboxes

Write code in your browser (use Chrome Developer Tools console) that will mark all checkboxes as checked.

You can use this sample html page https://jsbin.com/yanekuciya/1/edit?html,js,output

About

Le Wagon workshop 'JS for beginners'