Find the Position
When provided with a letter, return its position in the alphabet.
function position(alphabet: string): string {
const position = "abcdefghijklmnopqrstuvwxyz".split('').indexOf(alphabet) + 1;
return `Position of alphabet: ${position}`;
}
console.log(position("c"));
package main
import (
"fmt"
"strings"
)
func position(alphabet string) string {
position := strings.Index("abcdefghijklmnopqrstuvwxyz", alphabet) + 1
return fmt.Sprintf("Position of alphabet: %d", position)
}
func main() {
fmt.Println(position("c"))
}
def position(alphabet):
position = "abcdefghijklmnopqrstuvwxyz".index(alphabet) + 1
return f"Position of alphabet: {position}"
print(position("c"))
function position($alphabet) {
$position = strpos("abcdefghijklmnopqrstuvwxyz", $alphabet) + 1;
return "Position of alphabet: $position";
}
echo position("c");
Go to Kata
Want us to give you some help with your business? No problem, here's a video on who we can help, and how, along with our calendar so you can book in a call to discuss us working together.
Let's see