forked from HackYourFuture/JavaScript1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoreJs-11.js
More file actions
31 lines (24 loc) · 927 Bytes
/
moreJs-11.js
File metadata and controls
31 lines (24 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
Use the list of vehicles to write an advertisement.
So that it prints something like:
"Amazing Joe's Garage, we service cars,
motorbikes, caravans and bikes.".
(Hint: use a for loop.)
** below moreJs-10.js **
function advertisement(){
let vehicles = [' motorbike' , ' caravan', ' bike', ' car'];
// variable 'vehicles' is can be read from moreJs-7and8.js
// but i used it again inside of function to show you,
// and in case you can run in a html seperately.
let products = [];
for(i=0; i<vehicles.length; i++){
products.push(vehicles[i]+'s');
}
let lastTwoProduct = products[products.length - 2] + ' and ' + products[products.length - 1] ;
console.log(lastTwoProduct);
products.splice(2, 2,);
console.log('Amazing Abdullah\'s Garage, we sell ' + products.join() + ',' + lastTwoProduct +'.');
}
*/
vehicles.push('turck', 'scooter');
advertisement();