Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




endsWith() - FUNCTION


endsWith() Function


The endsWith() Function is used to check, if a String ends with a particular substring.


Example :



<html>
<body>  
<script>

	var x = "Hello Beautiful World"
    var y = x.endsWith("World")
    
	if (y == true) {
		document.write("The String ends with World")
	}	
	else {
		document.write("The String does not end with World")
	}
    
</script>      
</body>
</html>


Output :



  The String ends with World

In the above code, we have declared a String Hello Beautiful World and assigned it to a variable x.


x = "Hello Beautiful World"
java_Collections


And we have checked if the String, Hello Beautiful World ends with the substring World.


if (y == true) {
	document.write("The String ends with World")
}
else {
	document.write("The String does not end with World")
}

And in this case the String, substring Hello Beautiful World ends with the substring World


And thus we get the below output.


The String ends with World