<HTML>
<body>
</body>
<script>
function unique(arr){
return Array.from(new Set(arr));
}
let values = ["Hare", "Krishna", "Hare", "Krishna",
"Krishna", "Krishna", "Hare", "Hare", ":-O"
];
//alert( unique(values) ); // Hare, Krishna, :-O
alert(unique(values));
</script>
</HTML>
<!--
//not likely with object, map does not change the key to be string
//map can also use object as keys
my solution
let uniqueSet = new Set();
for(let item of arr){
uniqueSet.add(item);
}
for(let value of uniqueSet) alert(value);
//the condition of the task was returning a real arary
i wasnt aware of it lol
-->
<body>
</body>
<script>
function unique(arr){
return Array.from(new Set(arr));
}
let values = ["Hare", "Krishna", "Hare", "Krishna",
"Krishna", "Krishna", "Hare", "Hare", ":-O"
];
//alert( unique(values) ); // Hare, Krishna, :-O
alert(unique(values));
</script>
</HTML>
<!--
//not likely with object, map does not change the key to be string
//map can also use object as keys
my solution
let uniqueSet = new Set();
for(let item of arr){
uniqueSet.add(item);
}
for(let value of uniqueSet) alert(value);
//the condition of the task was returning a real arary
i wasnt aware of it lol
-->
댓글
댓글 쓰기