I need to set up a Javascript function that asks for strange string input (lots of capital and small letters), then takes this, corrects the typing, and returns the corrected value. Here's what I have so far:
//in the <head>
var place
var capitalLetter
var smallLetters
function proper() {
place = prompt("Please enter the name of a place. And type it all wonky (lots of capital letters).", "Location Name.");
var firstLetter = place.substring(0,1);
var theRest = place.substring(1);
capitalLetter = firstletter.toUpperCase();
smallLetters = theRest.toLowerCase();
}
//in the <body>
proper();
document.write("<p>You entered: " + place +". Which I corrected to: " + capitalLetter + smallLetters + ".</p>");
But, as it stands, the function runs, it asks for the text, and then nothing. What am I doing wrong?