How to use includes() Method In Javascript
In this approach, we are using the includes() method. Here we have used the for loop to go through the each character of the letter variable. For every letter, we are checking if the character is present in the inputStr variable using the includes() method. If the character is not present, then it is added in the output variable and printed.
Example: In this example, we will print Missing characters to make a string Pangram in JavaScript using includes() Method.
let inputStr = "welcome to w3wiki";
let letters = "abcdefghijklmnopqrstuvwxyz";
let output = "";
inputStr = inputStr.toLowerCase();
for (let c of letters) {
if (!inputStr.includes(c)) {
output += c;
}
}
console.log(output);
Output
abdhijnpquvxyz
JavaScript Program to Find Missing Characters to Make a String Pangram
We have given an input string and we need to find all the characters that are missing from the input string. We have to print all the output in the alphabetic order using JavaScript language. Below we have added the examples for better understanding.
Examples:
Input : welcome to w3wiki
Output : abdhijnpquvxyz
Input : The quick brown fox jumps
Output : adglvyz
Table of Content
- Using Set
- Using includes() Method
- Using indexOf() Method
- Using a Map
- Using Set and Range of ASCII Values