Skip to content

Commit

Permalink
passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesscha committed Apr 29, 2020
1 parent ccaba27 commit edd38ce
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions completion.js
@@ -1,14 +1,18 @@
function solution(participant, completion) {
let answer = []
for (let i = 0; i < participant.length; i++) {
if ( completion.includes(participant[i]) === false){
return participant
}else{
const idx = completion.indexOf(participant[i])
completion.splice(idx, 1)
}
}
return answer[0];
let ret = []
let hased = []
participant.forEach(entry => {
hased[entry] = hased[entry] ? hased[entry] + 1 : 1
})
completion.forEach(entry => {
hased[entry] = hased[entry] -1
})

for (let key in hased) {
if (hased[key] >= 1 ) return key
}


}

console.log(solution(["marina", "josipa", "nikola", "vinko", "filipa"], ["josipa", "filipa", "marina", "nikola"]))

0 comments on commit edd38ce

Please sign in to comment.