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 1: Write a method that takes in an array of numbers and returns an array with all number whose digits add up to an even number removed. The sum of the digits for
13 is 4, so it would be removed. The sum of the digits for
124 is 7, so it would not be removed.
Prompt 2: Write a method that takes in an array of numbers and a number (
n) and returns the array with the multiples of
choiceis "true", then the method should behave as normal. If
false, then numbers whose digets sun to an odd number should be removed.
number. The method should filter the input array to remove all numbers whose digits add up to
Alter your method such that it takes a third parameter called
choice is "multiples", then the method 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 method to keep your code organized.
Alter your method 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 ])