#Can someone explain to me why my code isn't passing in HackerRank?

18 messages · Page 1 of 1 (latest)

neon silo
#

I was assigned to do this Write a function called dedupe which accepts an array of integers and returns a new array with all duplicates removed.

dedupe([1,2,4,4,1,2]) // [1,2,4]
dedupe([5,15,12,1,3]) // [5,15,12,1,3]
dedupe([4,4,4,4,4]) // [4]
dedupe([4,6,5,3]) // [4,6,5,3]
dedupe([1,2,1,2]) // [1,2]

This is the code I placed in HackerRank ```js

function dedupe(numbers) {
return [...new Set(numbers)];
}

console.log(dedupe([1,2,4,4,1,2])); // [1,2,4]
console.log(dedupe([5,15,12,1,3])); // [5,15,12,1,3]
console.log(dedupe([4,4,4,4,4])); // [4]
console.log(dedupe([4,6,5,3])); // [4,6,5,3]
console.log(dedupe([1,2,1,2])); // [1,2]

It says Test Case 1 Your Output [1,2,4] expected 5
covert blaze
#

What's the test case?

neon silo
#

one sec

neon silo
neon silo
covert blaze
#

Huh interesting

#

That should work?

neat current
#

what is the expected output

#

why is it like that

neon silo
# neat current why is it like that

None of it made it sense. It compiled fine but didn't pass any test case. Either way I submitted hopefully the company understands the code is correct or I made an attempt

covert blaze
#

This was a company assessment?

neon silo
native iron
#

looks like it's expecting each entry printed one by one, not the array printed

#

wait the expected output starts at the second test?

#

maybe remove the console.logs?

#

that you manually added(?)