Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
1-liner: Concept of Set & size solution in Clear category for All the Same by --Serial_Sniper--
import assert from "assert";
function allTheSame(elements: any[]): boolean { return new Set(elements).size <= 1; }
console.log('Example:')
console.log(allTheSame([1, 1, 1]))
// These "asserts" are used for self-checking and not for an auto-testing
assert.equal(allTheSame([1, 1, 1]), true)
assert.equal(allTheSame([1, 2, 1]), false)
assert.equal(allTheSame(['a', 'a', 'a']), true)
assert.equal(allTheSame([]), true)
assert.equal(allTheSame([1]), true)
console.log("Coding complete? Click 'Check' to earn cool rewards!");
June 7, 2020