I have an exercise where I need a user to create a rhyme with specific starting letters. If the starting letters are correct in the inputText boxes, I want to execute something and if not, something else.
Besides checking whether the first letters are correct, I also want to print the words from the textBoxes into a messageBox.
I can check if they are correct, but don’t know how to retrieve the actual completed text words and print them in my messageBox. My attempt lacks insight.
var inputText = document.getElementById('myTextarea1').value; // string
var inputText2 = document.getElementById('myTextarea2').value; // string
var messageBox = document.getElementById('messageBox1');
if ((inputText.charAt(0) == 'a') && (inputText2.charAt(0) == 'b')) {
messageBox.innerHTML = (inputText + inputText2 ); // string + string
//
} else {
messageBox.innerHTML = "Sorry, the first letters of your rhyme do not match the series";
}