0% found this document useful (0 votes)
6 views

JS Exercise2

Another javascript questions

Uploaded by

markgreezy2k19
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

JS Exercise2

Another javascript questions

Uploaded by

markgreezy2k19
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Exercise

1. Write a JavaScript program that iterates integers from 1 to 20. But for multiples of three print "Fizz"
instead of the number and for multiples of five print "Buzz". For numbers multiples of both three and
five print "FizzBuzz".

2.

a. Create a function removeEgg(foods) that takes an array of strings and returns an array where the
string “egg” is removed.

* removeEgg([‘egg’, ’apple’, ‘egg’, ‘egg’, ‘ham’]) => [‘apple’, ‘ham’]

b. Update the above to only remove the first 2 eggs from the array.

c. Update 2.a to only remove the last 2 eggs from the array and reverse the order of the values.

3.

a. Let’s say we have a basketball project. This product has a name of “basketball” and a price of
10,000br. Create an object to represent this product and display it in the console.

b. Increase the price by 500br. Use dot notation to increase the price, and display the object in the
console.

c. Using bracket notation, add a property ‘delivery-time’ to the object with the value ‘3 days’. Display the
updated object in the console.

d. Create a function ‘comparePrice(product1, product2)’, which takes 2 products (with ‘name’ and ‘price’
properties) and returns the product that is less expensive. Create 2 products and try out the function.

You might also like