Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Remove all repeating elements from the array.
- function solve(input) {
- let uniqueArr= new Set(input);
- const backToArray = [...uniqueArr]
- console.log(backToArray.join(' '));
- }
- //alternative code
- function solve(input) {
- let uniqueArr=[];
- for (let i = 0; i < input.length; i++) {
- let indexOfEl=input.indexOf(input[i]);
- if (i===indexOfEl) {
- uniqueArr.push(input[i]);
- }
- }
- console.log(uniqueArr.join(' '));
- }
Advertisement
Add Comment
Please, Sign In to add comment