JavaScript Strings with Practical Examples
Free Web development courses with real-time projects Start Now!!
Program 1
//let s1="dataflair indore" "use strict" const ps=require("prompt-sync") const prompt=ps({sigint:true}) let s1=prompt("Enter a string") //console.log(s1.length) //console.log(s1.charAt(3)) data flair let count=0 let i for(i=0;i<s1.length;i++) { if(s1.charAt(i)==' ') count++ } console.log("Total space character is: " + count) // count total vowel character from string // print string in reverse
Program 2
"use strict" const ps=require("prompt-sync") const prompt=ps({sigint:true}) let s1=prompt("Enter a string") let i for(i=0;i<s1.length;i++) { console.log(s1.charCodeAt(i)) }
If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google