STRING STARTS AND ENDS WITH CERTAIN CHARACTERS
************************************************************************
W.A.P TO CHECK WEATHER A STRING STARTS AND ENDS WITH CERTAIN CHARACTERS
************************************************************************
JAVA Program
Output:
************************************************************************
C Program 
Online Compiler ************************************************************************
C++ Program 
Online Compiler
************************************************************************
C# Program 
  
************************************************************************
PHP Program
Php is a server side scripting language.
************************************************************************
JAVASCRIPT Program
 <script type="text/javascript">
var string = prompt("Please enter a string: ");
var substring = "the";
var testStart= string.startsWith('W');
var testEnd = string.endsWith('e');
console.log(`Starts: ${testStart}`);
console.log(`Ends: ${testEnd}`);
if (testStart && testEnd)
{
  console.log(`${string} starts with W and ends with e`);
}
else if(testStart && !testEnd)
{
  console.log(`${string} starts with W but does not ends with e`);
}
else if(!testStart && testEnd)
{
  console.log(`${string} does not starts with W but ends with e`);
}
else if(!testStart && !testEnd)
{
  console.log(`${string} does not starts with W and does not ends with e`);
}
</script> 
************************************************************************  
PYTHON Program
 
************************************************************************   
Comments
Post a Comment