Skip to content

Psterne/javascript_exercises

Repository files navigation

javascript

This folder contains:

1 --- Various exercises completed as homework for POWr Code School.

1.1 A Calculator built in jQuery.

1.2. A comparison tool that sets <, >, and = after comparing two numbers.

2 --- Answers to some of the JS exercises on this page:

http://www.ling.gu.se/~lager/kurser/webtechnology/lab4.html

Ten Simple Javascript Exercises

2.1. Define a function max() that takes two numbers as arguments and returns the largest of them. Use the if-then-else construct available in Javascript.

2.3. Write a function that takes a character (i.e. a string of length 1) and returns true if it is a vowel, false otherwise.

2.5. Define a function sum() and a function multiply() that sums and multiplies (respectively) all the numbers in an array of numbers. For example, sum([1,2,3,4]) should return 10, and multiply([1,2,3,4]) should return 24.

3 -- Answers to ARRAY exercises:

3.1 Create an array of numbers using 10,20,30, and 40 as values. Now update the value at each index of the array to be increased by 1. The end result should be an array of numbers with values 11,21,31,41.

3.2. Take the array in the previous example, create a new element with the value of 51at the end of the array. (Append 51 to the array).

3.3 Create an array of names with Super, Cali, Fragi, Listic, Expi, Ali, Docious as values.Combine these components together into a single string by concatenating them together.

3.4 Starting with the same array as in the previous ex, create the string Super-Cali-Fragi-Listic-Expi-Ali-Docious using join().

4 -- Answers to LOOP exercises:

4.1. Create an array of numbers using 10,20,30, and 40 as values. Create a loop to update the value at each index of the array to be increased by 1. The end result should be an array of numbers with values 11,21,31,41.

4.2. Create an array of names with Super, Cali, Fragi, Listic, Expi, Ali, Docious as values.Use a forEach loop to combine these components together into a single string.

4.3. Using the array from Ex 1, find the average of the numbers in the array(average=sum of all numbers/number of numbers).

5 -- Answers to OBJECTS exercises:

5.1. Write a JavaScript program to list the properties of a JavaScript object.

5.2. Write a JavaScript program to delete the one of the properties from the object in 5.1. Also print the object before or after deleting the property.

5.3. Write a JavaScript program to get the length of an JavaScript object.

5.4. Write a JavaScript program to display the reading status (i.e. display book name, author name and reading status) of the following books.

  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
     }];

5.8. Write a JavaScript program to create a Clock. Go to the editor

  Note : The output will come every second.
  Expected Console Output :
  "14:37:42"
  "14:37:43"
  "14:37:44"
  "14:37:45"
  "14:37:46"
  "14:37:47"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published