Advertisement
dilyana2001

Untitled

Jul 15th, 2021
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function partyTime(strArr) {
  2.     let list = {
  3.         vip: [],
  4.         regular: []
  5.     }
  6.     let name = strArr.shift()
  7.     while (name !== 'PARTY') {
  8.         let char = name[0]
  9.         if (isNaN(char)) {
  10.             list.regular.push(name)
  11.         } else {
  12.             list.vip.push(name)
  13.         }
  14.         name = strArr.shift()
  15.     }
  16.     strArr.forEach(guest => {
  17.         if (list.vip.includes(guest)) {
  18.             let index = list.vip.indexOf(guest)
  19.             list.vip.splice(index, 1)
  20.         } else if (list.regular.includes(guest)) {
  21.             let index = list.regular.indexOf(guest)
  22.             list.regular.splice(index, 1)
  23.         }
  24.     })
  25.     console.log(list.vip.length + list.regular.length)
  26.     console.log(`${list.vip.join('\n')}\n${list.regular.join('\n')}`)
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement