ovi-salman / JS-Exercises

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JS Exercises

Task 1:

Add JS to HTML

  • Directly in HTML
  • External script

Task 2:

Write a function that returns the sum of a given array.


Task 3:

Write a function that checks if a given string is a valid e-mail address.

HINT: /^\w+([.-]?\w+)@\w+([.-]?\w+)(.\w{2,3})+$/


Task 4:

Given the following array of objects, write a function that prints the status at a given index:

var library = [
   {
       author: 'Bill Gates',
       title: 'The Road Ahead',
       readingStatus: true
   },
   {
       author: 'Steve Jobs',
       title: 'Walter Isaacson',
       readingStatus: true
   },
   {
       author: 'Suzanne Collins',
       title:  'Mockingjay: The Final Book of The Hunger Games', 
       readingStatus: false
   }];

Task 5:

Find the total cost of the items in the given cart:

var cart = [ 
   {
       name: 'Shoes',
       price: 560,
       quantity: 4
   },
   {
       name: 'Regular Tees',
       price: 455.50,
       quantity: 6
   },
   {
       name: 'Socks',
       price: 65.99,
       quantity: 2
   }];

About


Languages

Language:JavaScript 76.7%Language:HTML 23.3%