Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function partyTime(strArr) {
- let list = {
- vip: [],
- regular: []
- }
- let name = strArr.shift()
- while (name !== 'PARTY') {
- let char = name[0]
- if (isNaN(char)) {
- list.regular.push(name)
- } else {
- list.vip.push(name)
- }
- name = strArr.shift()
- }
- strArr.forEach(guest => {
- if (list.vip.includes(guest)) {
- let index = list.vip.indexOf(guest)
- list.vip.splice(index, 1)
- } else if (list.regular.includes(guest)) {
- let index = list.regular.indexOf(guest)
- list.regular.splice(index, 1)
- }
- })
- console.log(list.vip.length + list.regular.length)
- console.log(`${list.vip.join('\n')}\n${list.regular.join('\n')}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement