Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Strings</h1>
<h2>The endsWith() Method</h2>
<p>endsWith() returns true if a string ends with a specified string, otherwise false.</p>
<p>Check if the 11 first characters of "Hello world" ends with "world":</p>
<p id="demo"></p>
<script>
let str = "Hello world, welcome to the universe.";
document.getElementById("demo").innerHTML = str.endsWith("world", 11);
</script>
</body>
</html>