Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
546 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Software ==> | OfficeScripts (21 exercises) |
Topic ==> | Arrays (4 exercises) |
Level ==> | Relatively easy |
Subject ==> | Office Scripts training |
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
Open the Pizzas.xlsx file and create a new script. The aim of the exercise is to use an array to populate a list of your favourite pizza toppings.
If you're happy with the existing list feel free to leave it as it is!
Create an array to hold your three favourite pizza toppings and store the result in a variable (if you don't like pizza, pick your favourite ice-cream flavours or equivalent substitute).
Use the sort method on the array and then write it to the Output window using the console.log method.
Office Scripts clearly has no problem with our choices so far.
Just in case you've neglected to add the best topping, write an if statement which uses the includes method to check if your array contains Pineapple. If not, use the push method to add this item to the array.
There is no need to shake the tree after doing this.
You may have accidentally infected your list of delicious food with a fungus. Use the indexOf method to return the index of Mushrooms in your array. Check if the result is greater than -1 and, if so, use the splice method to remove the offending item.
You could use the optional third parameter to replace Mushrooms with Pineapple...
Use the toString method to store the contents of the array in a comma-separated string and write this into cell A2 on the Pizzas worksheet. You could add code to clear the existing list of toppings first.
The list of toppings should appear in a single cell.
Change your script to loop over the contents of the array and write each item into a separate cell, starting from A3.
You could use a while loop, a for loop, a for of loop, or the forEach method to do this.
Run the script to see your list of favourite toppings in the worksheet.
The final list.
Save and close the script and workbook.
You can find other training resources for the subject of this exercise here:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2025. All Rights Reserved.