I'm in the process of creating a program to convert any text string to Morse Code in a straightforward manner. As a beginner in programming, I'd appreciate any advice on methods I could utilize.
At the moment, I've defined a phrase (string) and an array containing the Morse Code equivalents, but I'm struggling with the next steps of extracting each character from the string, comparing it with the array, and outputting the Morse Code representation of the string.
var sentence = "sink or swim";
var morse = [".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."];
for(i=0; i<sentence.length; i++){
char = sentence.charAt(i);
WScript.echo(char + " | " + i);
}