@@ -5,22 +5,19 @@ Use the list of vehicles to write an advertisement.
55motorbikes, caravans and bikes.".
66(Hint: use a for loop.)
77*/
8- function advertisement ( ) {
9- // let vehicles = [' motorbike' , ' caravan', ' bike', ' car'];
10- // variable 'vehicles' is can be read from moreJs-7and8.js
11- // but i used it again inside of function to show you,
12- // and in case you can run in a html seperately.
13- let products = [ ] ;
14- for ( i = 0 ; i < vehicles . length ; i ++ ) {
15- products . push ( ' ' + vehicles [ i ] + 's' ) ;
16- }
17- let lastTwoProduct = products [ products . length - 2 ] + ' and' + products [ products . length - 1 ] ;
18- console . log ( lastTwoProduct ) ;
19- products . splice ( ( products . length - 2 ) , 2 , ) ;
20-
21- console . log ( 'Amazing Abdullah\'s Garage, we sell ' + products . join ( ) + ',' + lastTwoProduct + '.' ) ;
22-
8+ function advertisement ( ) {
9+ // let vehicles = [' motorbike' , ' caravan', ' bike', ' car'];
10+ // variable 'vehicles' is can be read from moreJs-7and8.js
11+ // but i used it again inside of function to show you,
12+ // and in case you can run in a html seperately.
13+ let products = [ ] ;
14+ for ( i = 0 ; i < vehicles . length ; i ++ ) {
15+ products . push ( ' ' + vehicles [ i ] + 's' ) ;
16+ }
17+ let lastTwoProduct = products [ products . length - 2 ] + ' and' + products [ products . length - 1 ] ;
18+ console . log ( lastTwoProduct ) ;
19+ products . splice ( products . length - 2 , 2 ) ;
2320
21+ console . log ( "Amazing Abdullah's Garage, we sell " + products . join ( ) + ',' + lastTwoProduct + '.' ) ;
2422}
2523advertisement ( ) ;
26-
0 commit comments