Code

Javascript code posted by Zunair Khokhar
created at 15 Oct 15:49, updated at 15 Oct 22:02

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<p>Click below to get started!</p>

<button onclick="outputPosition()">&#9786;</button>

<p id="paragraph"></p>

<script>
function outputPosition()
{
var x;
var letter=prompt("Enter any letter of the alphabet.");
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
var y = alphabet.indexOf(letter) + 1
if (letter!=null)
  {
  x="The position of " + letter + " is " + y;
  document.getElementById("paragraph").innerHTML=x;
  }
}
</script>
459 Bytes in 3 ms with coderay