Given an array of size 3X+1, where every element occurs three times, except one element, which occurs only once. Find the element that occurs only once. code example
Example 1: Given an array of integers, every element appears thrice except for one which occurs once.
let contacts = new Map()
contacts.set('Jessie', {phone: "213-555-1234", address: "123 N 1st Ave"})
contacts.has('Jessie')
contacts.get('Hilary')
contacts.set('Hilary', {phone: "617-555-4321", address: "321 S 2nd St"})
contacts.get('Jessie')
contacts.delete('Raymond')
contacts.delete('Jessie')
console.log(contacts.size)
Example 2: create a function that takes in an array of numbers and returns only the number that are even after 1 is added to the value
const evenAfter = (arr) => {
let i = 0
let newArr = []
while (i <= arr.length) {
if ((arr[i] + 1) % 2 === 0){
newArr.push(arr[i])
}
i++
}
return newArr
}
console.log(evenAfter([3,6,7,8,9,11]))