I have a name input checker using Javascript and I'm struggling to see the issue. When the input has been entered and matches the array, the site should return ("Welcome" . inputValue) as an alert. However, I am getting an alert but it only says "undefined". If the person types in the incorrect name (doesn't match the array) it does feedback "User not know" As it is meant to. So the only issue is when the input value matches the array it gives the result "undefined".
var x = ["Bob", "James", "Alan", "Emilie", "Donna", "Ashleigh", "Arthur", "John"];
function checkInput() {
var inputValue = document.getElementById("inputString").value;
var test = x.indexOf(inputValue);
if (test >= 0)
alert("Welcome ".inputValue);
else
alert("User not known");
}
<form>
<input type="text" id="inputString">
<button onclick="checkInput()">Evaluate input</button>
</form>
+operator, not the period (.).