When and how whiteboarding practice is implemented will be up to your teacher. Below is a recommended prompt.
For this week’s whiteboarding lesson, we’ll focus on using arrays and loops to assess a string.
As the interviewee:
As the interviewer:
Prompt: Write a function that takes in an array of numbers and a number (
n) and returns the array with the multiples of
Alter your function such that it takes a third parameter called
choice is "multiples", then the function should behave as normal. If
factors, numbers that are factors of
n should be removed from the array. (i.e. Given: [ 1, 9, 6, 1, 3, 10, 12, 99, 2] , 12, "factors"; Return: [ 9, 10, 99 ]). You should create a helper function to keep your code organized.
Alter your function to accept an array of numbers as the second parameter. Remove the multiples/factors of each of these numbers from the original array and return the filtered array. (i.e. Given: [ 1, 9, 6, 1, 3, 10, 12, 99, 2] , [ 3, 5 ], "multiples"; Return: [ 1, 1, 99, 2 ])