Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let result = [];
- let words = input.split(" ");
- for (let word of words) {
- if (word.length > 1 && word.startsWith("#")) {
- result.push(word.substring(1));
- }
- }
- let final = [];
- for (let word of result) {
- let ch = word.split("");
- let chL = ch.length;
- let flag = true;
- for (let i = 0; i < chL; i++) {
- let currWord = ch[i].charCodeAt(0);
- if (
- (currWord < 97 || currWord > 122) &&
- (currWord < 65 || currWord > 90)
- ) {
- flag = false;
- }
- }
- if (flag) {
- final.push(word);
- }
- }
- final.forEach((word) => console.log(word));
- }
- solve("Nowadays everyone uses # to tag a #special word in #socialMedia");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement