const text = "I like javascript";
const result = text.toUpperCase();
console.log(result);
Output
I LIKE JAVASCRIPT
const text = "I LIKE JAVASCRIPT";
const result = text.toLowerCase();
console.log(result);
Output
i like javascript
const text1 = "JavaScript";
const text2 = "Programming";
const result = text1.concat(text2);
console.log(result);
Output
JavaScriptProgramming
const text = "Hello. My name is Punit."
console.log(text);
const result = text.replace("Hello", "Hi");
console.log(result);
Output
Hi. My name is Punit.
const text = "hello";
const result = text.split('');
console.log(result);
Output
["h", "e", "l", "l", "o"]
const text = "JavaScript";
const result = text.slice(0,4);
console.log(result);
Output
Java
const text = " JavaScript ";
const result = text.trim();
console.log(result);
Output
JavaScript
const text = "JavaScript is fun.";
const result = text.search("fun");
console.log(result);
Output
14
const text = "JavaScript is fun.";
const result = text.search("funny");
console.log(result);
Output
-1
Create a string "I love Java". Convert the string to lowercase and check if the string consists of the substring "java". If yes, replace the substring "java" with "JavaScript".
const text = "I love Java.";
const smallcase = text.toLowerCase();
const checkValue = smallcase.includes('java');
if(checkValue) {
const result = smallcase.replace('java', 'JavaScript');
console.log(result);
}
Output
i love JavaScript.
Q. What is the output of the program?
const message = "JavaScript is fun";
const result = message.split(' ');
const value = result[0].charAt(2);
console.log(value);
- s
- v
- is
- fun
Answer: 2