Problem Statement:
We are given a string, we need to convert that string to an array, array should contain all characters of the string as elements. There should be only unique characters in the array.
For example- myStr = 'I Love CopyAssignment'
=> [ 'I', 'L', 'o', 'v', 'e',
'C', 'p', 'y', 'A', 's',
'i', 'g', 'n', 'm', 't', '' ]
Code for Unique characters in a String in JavaScript:
myStr = 'I Love CopyAssignment'; arr = [] for(let i=0; i<myStr.length; i++){ if(arr.includes(myStr[i])){ continue; }else{ arr.push(myStr[i]); } } arr.push('') arr = arr.filter(v => v !== ' '); console.log(arr)
Output:

Also Read:
- The system of the binary conversion
- What is web development for beginners?
- Guide to Proxy Servers: How They Work and Why You Need Them?
- Python | Check Armstrong Number using for loop
- Python | Factorial of a number using for loop
- Link in bio
- Microsoft Giving Free Machine Learning Course: Enroll Now
- Accenture Giving Free Developer Certificate in 2023
- Python | Asking the user for input until they give a valid response
- Python | How to iterate through two lists in parallel?
- Amazon Summer Internship 2023
- Python | How to sort a dictionary by value?
- Amazon Giving Free Machine Learning Course with Certificate: Enroll Now
- Google Summer Internship 2023
- Python | How to split a list into equally-sized chunks?
- 5 Secret ChatGPT skills to make money
- Python | Remove items from a list while iterating
- Free Google Certification Courses
- 5 AI tools for coders better than ChatGPT
- Python | How to get dictionary keys as a list
- New secrets to Earn money with Python in 2023
- Flower classification using CNN
- How to represent Enum in Python?
- 5 methods | Flatten a list of lists | Convert nested list into a single list in Python
- What does if __name__ == __main__ do in Python?
- Music Recommendation System in Machine Learning
- Brick Breaker Game in C++
- Dino Game in Java
- Java Games Code | Copy And Paste
- How to utilize ChatGPT to improve your coding skills?