Full Stack Web Development Courses with Real-time projects Start Now!!
Program 1
// String in Java Script
"use strict"
const ps=require("prompt-sync")
const prompt=ps({sigint:true})
let str
str="This is a class of JS , This is a class of Java Script , This is a class of string in java script"
console.log(str.indexOf("class")) // int
console.log(str.search("class")) // int
// console.log(str.lastIndexOf("class")) // int
// console.log(str.includes("class")) // boolean
// console.log(str.match("class")) // array
/*
indexOf()
includes()
match()
*/
Program 2
// String in Java Script
// mutable and immutable
let str="DataFlair" //immutable (non change)
// str=str.concat(" Indore MP")
str=str +" Indore MP"
console.log(str)
console.log(10+10) //addition
console.log(10.5+10.5) //addition
console.log(true+true)//addition
console.log("10"+10) //concat
console.log("10"+"10") //concat
Program 3
// String in Java Script
"use strict"
const ps=require("prompt-sync")
const prompt=ps({sigint:true})
// let s=prompt("Enter Doctor Name: ")
// s=s.toUpperCase()
// //console.log(s.startsWith("DR"))
// if(s.startsWith("DR"))
// console.log("Its valid name")
// else
// console.log("Its Invalid name")
// let s=prompt("Enter a string: ")
// s=s.toUpperCase()
// console.log(s.endsWith("INDORE"))
//let s=prompt("Enter a string: ")
let s="This is a class of JS ,This is a class of Java Script , This is a class of string in java script"
//console.log(s.substring(10))
// s=s.replaceAll("python","Java Script")
// console.log(s)