Js an array with several empty items. Output

arr.forEach((item, idx) => {
        if (item == "") {
          switch (idx) {
            case 0:
              console.log("")
              break;
            case 1:
              console.log("")              
              break;
            case 2:
              console.log("")              
              break;
            case 3:
              console.log("")              
              break;
            case 4:
              console.log("")              
              break;
          }
        }
        
      })

now the output is to print out all the empty items. What I want to get is that even if all five item inputs are empty, there is only one printed result
. Any one will do. Excuse me, how can it be realized?

Nov.14,2021

var i = arr.findIndex(item => item == '')

then judge

according to I

const status = [
  '0',
  '1',
  '2',
  '3',
  '4',
  '5',
  '6',
]
arr.forEach((item, idx) => {
  if (item == '') {
    console.log(status[idx])
  }
})

like this?


let arr = ['', '', '']
let flag = false
arr.forEach((item, idx) => {
    if (item == '') {
        flag = true
    }
})
if (flag) {
    console.log('');
}

arr.find ((item, index) = > {console.log ("th" + (index+1) + "case"); return item =';});

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46612-270e9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46612-270e9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?