Results 1 to 3 of 3

Thread: [RESOLVED] Trouble with .substring() and changing case

Hybrid View

  1. #1
    Join Date
    Apr 2014

    resolved [RESOLVED] Trouble with .substring() and changing case

    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:

    PHP Code:
    //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.");
    firstLetter place.substring(0,1);
    theRest place.substring(1);
    capitalLetter firstletter.toUpperCase();
    smallLetters theRest.toLowerCase();

    //in the <body>
    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?

  2. #2
    Join Date
    Mar 2005
    Behind you...
    It's the little things really... Watch your variable names as they are case sensitive (which is wildly ironic given the script's purpose)
    var firstLetter = place.substring(0,1);
    capitalLetter = firstletter.toUpperCase();
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

  3. #3
    Join Date
    Apr 2014
    That's twice now I've missed the "little things". Thanks! I need to start using the console more... I keep forgetting about it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles