I don't know what I'm doing

const arr = prompt(‘Enter a list of number separated by a comma. For example: 1,2,3: ‘).split(’,’).map(x => parseInt(x));
const elements = prompt(‘Enter a list of number separated by a comma to remove from the list above: ‘).split(’,’).map(x => parseInt(x));

/**

  • Creates a new array after removing all of the given elements
  • from the given array.
  • For example: if arr = [1, 2, 3] and elements = [1, 3], it
  • should return [2].
    */

const result = ;

for (let i = 0; i < numbers.length; i++) {
result.push(square(numbers[i]));
}

console.log(result);

I’d use .includes to check whether an array contains some element, in an if-statement inside the loop.

const result = [];

for (let i = 0; i < numbers.length; i++) {
  if (!elements.contains(numbers[i]) { // if elements does not contain it
    result.push(numbers[i]); // add it to result array
  }
}

Or, you can use .filter to remove all the elements not in a given other array.

const result = elements.filter(x => !elements.contains(x));