21
loading...
This website collects cookies to deliver better user experience
let text = "Hello JavaScript";
let letter = text.charAt(0);
console.log(letter)
/* Output:
H
*/
let text = "Hello JavaScript";
let code = text.charCodeAt(0);
console.log(code)
/* Output:
72
*/
let text1 = "Hello";
let text2 = "JavaScript";
let result = text1.concat(text2);
console.log(result)
/* Output:
Hello JavaScript
*/
let text = "Hello world";
let result = text.endsWith("Hello");
console.log(result)
/* Output:
false
*/
let text = "Hello JavaScript, welcome to the JavaScript world.";
let result = text.includes("welcome");
console.log(text)
/* Output:
true
*/
let text = "Hello JavaScript, welcome to the JavaScript world.";
let result = text.indexOf("JavaScript");
console.log(text)
/* Output:
0
*/
let text = "Hello planet earth, you are a great planet.";
let result = text.lastIndexOf("planet");
console.log(text)
/* Output:
36
*/
let text1 = "abc";
let text2 = "def";
let result = text1.localeCompare(text2);
console.log(result)
/* Output:
-1
*/
repeat()
Returns a new string with a specified number of copies of an existing string.
let text = "Hello JavaScript! ";let text = "Hello PHP, welcome to the PHP world.";
let result = text.replace("PHP", "JavaScript");
console.log(result)
/* Output:
Hello JavaScript, welcome to the JavaScript world.
*/
let text = "Hello JavaScript, welcome to the JavaScript world."
let position = text.search("world");
console.log(position )
/* Output:
44
*/
let text = "Hello JavaScript";
let result = text.slice(0, 10);
console.log(result )
/* Output:
Hello Java
*/
let text = "Hello JavaScript, welcome to the JavaScript world."
const myArray = text.split(" ");
console.log(myArray)
/* Output:
[ "Hello", "JavaScript,", "welcome", "to", "the", "JavaScript", "world." ]
*/
let text = "Hello World!";
let result = text.toLowerCase();
console.log(result);
/*
Output:
hello world
*/
let text = "Hello World!";
let result = text.toUpperCase();
console.log(result);
/*
Output:
HELLO WORLD
*/
let text = " Hello World! ";
let result = text.trim();
console.log(result);
/*
Output:
Hello World
*/