Remove element from array

I want to remove the second element("") from the newArray

  **Your code so far**

function steamrollArray(arr) {
let newArray = arr.toString()
newArray = newArray.split(/\,/g)
newArray = =>{
  if(val == "[object Object]"){
    return {}
  else if(val == ""){
  return "how to remove this one "
  else if(val.match(/[a-z]/g)){
return val
    return parseInt(val)
return newArray

console.log(steamrollArray([1, [], [3, [[4]]]]))

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36

Challenge: Steamroller

Link to the challenge:

I don’t think this will ever be true.

And I’m not sure this is a useful case.

I think perhaps you are confused about how the data is structured. You are working with a nested array. Each element is either A) an element on its own or B) a sub-array of elements. You should only have two cases.

1 Like

:sweat_smile: U r right, I’m only making this funtion to somehow just complete the task(not universal) and that’s bad. Now I’m tryin’ again to make it useful for each case this time . Thanks btw

You can use the arrayObject.filter() method to remove elements from an array at specific index in JavaScript.

var rValue = 'three'
var arrayItems = ['one', 'two', 'three', 'four', 'five', 'six']
arrayItems = arrayItems.filter(item => item !== rValue)

thanks buddy. This method is very useful