I need to create two functions, to request the user to type in a character and a string. The inputs are matched with a given string.
Then tell the user, if the input character/string is found in the default given string.
So far I have created the basics to get the user inputs, but couldn't find any method to implement the javascript functions. Any help would be highly appreciated.
Here's my code so far..!
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width shrink-to-fit=no initial-scale=1">
<title>Web Programming is fun!</title>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css"
integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l"
crossorigin="anonymous"
>
<style>
p{display: inline;}
</style>
</head>
<body>
<div class="container">
<h1>Web Programming is Fun!</h1>
<br>
<p>Lets use the above heading string to demonstrate inbuilt methods.</p>
<label for="inputCharacter">Please type a character: </label>
<input type="text" id="inputCharacter">
<button onclick="matchCharacter()">Match Character</button>
<p id="character"></p>
<br>
<label for="inputString">Please type a string: </label>
<input type="text" id="inputString">
<button onclick="matchString()">Match String</button>
<p id="string"></p>
<script>
let text ="Web programming is fun!";
function matchCharacter()
{
var char=document.getElementById("inputCharacer").innerHTML;
if(char.indexOf(text) )
{
alert("Your Character is found in the string!")
}
}
function matchSring()
{
}
</script>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous">
</script>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"
integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns"
crossorigin="anonymous">
</script>
</body>
</html>