<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Strings</h1>
<script>
let str1 = "Hello, AIT!";
let str2 = 'JavaScript Strings!';
console.log(str1); // Output: Hello, AIT!
console.log(str2);
</script>
</body>
</html>
Output:
Output: JavaScript Strings!
<!DOCTYPE html>
<html>
<body>
<h1>String Method</h1>
<h2>Lenght</h2>
<script>
let str = "Hello, AIT!";
console.log(str.length);
</script>
</body>
</html>
Output:
Output: 11
<!DOCTYPE html>
<html>
<body>
<h2>toUpperCase() and toLowerCase()</h2>
<script>
let str = "AIT Aurangabad";
console.log(str.toUpperCase()); // Output: Hello, AIT!
let str2 = "AIT Aurangabad";
console.log(str2.toLowerCase());
</script>
</body>
</html>
Output:
let str = "AIT Aurangabad";
Output: "AIT AURANGABAD"
Output: "ait aurangabad"
<!DOCTYPE html>
<html>
<body>
<h2>charAt()</h2>
<script>
let str = "Hello";
console.log(str.charAt(1));
</script>
</body>
</html>
Output:
Output: "e"
<!DOCTYPE html>
<html>
<body>
<h2>indexOf()</h2>
<script>
let str = "Hello, world!";
console.log(str.indexOf("world")); // Output: 7
console.log(str.indexOf("JavaScript"));
</script>
</body>
</html>
Output:
Output: 7
Output: -1 (not found)
<!DOCTYPE html>
<html>
<body>
<h2>substring()</h2>
<script>
let str = "JavaScript String";
console.log(str.substring(0, 10));
</script>
</body>
</html>
Output:
Output: "JavaScript"
<!DOCTYPE html>
<html>
<body>
<h2>split()</h2>
<script>
let str = "Hello World";
let arr = str.split(" ");
console.log(arr);
</script>
</body>
</html>
Output:
Output: ["Hello", "World"]
<!DOCTYPE html>
<html>
<body>
<h2>replace()</h2>
<script>
let str = "Hello, World!";
let newStr = str.replace("World", "JavaScript");
console.log(newStr);
</script>
</body>
</html>
Output:
Output: "Hello, JavaScript!"
<!DOCTYPE html>
<html>
<body>
<h2>trim()</h2>
<script>
let str = " Hello, World! ";
console.log(str.trim());
</script>
</body>
</html>
Output:
Output: "Hello, World!"
<!DOCTYPE html>
<html>
<body>
<h2>concat()</h2>
<script>
let str1 = "Hello";
let str2 = "World";
console.log(str1.concat(", ", str2, "!"));
</script>
</body>
</html>
Output:
Output: "Hello, World!"
<!DOCTYPE html>
<html>
<body>
<h2>Template Literals</h2>
<script>
let name = "Noorain";
let greeting = Hello, ${name}!;
console.log(greeting);
</script>
</body>
</html>
Output:
Output: "Hello, Noorain!"