www.webdeveloper.com
Results 1 to 5 of 5

Thread: New to Javascript, question about arrays

  1. #1
    Join Date
    Sep 2012
    Posts
    11

    New to Javascript, question about arrays

    Hi, thanks in advance for the help. i was wondering how I would find specific words in an array that end in a vowel (aeiou)?

  2. #2
    Join Date
    Nov 2010
    Posts
    1,084
    when exactly is your homework due?

  3. #3
    Join Date
    Nov 2006
    Location
    Oakland
    Posts
    500
    Given an array named myArray with your words you can use
    var results=myArray.filter(function(x) { return x.match(/[aeiou]$/i); });

    The "results" is an array of all words from myArray the end with a vowel.
    Don't forget "y" is a vowel too.

  4. #4
    Join Date
    Nov 2006
    Location
    Oakland
    Posts
    500
    Of course you can omit the /i in the regular expression since there is not reason for the last character of a word to be in uppercase.

  5. #5
    Join Date
    Sep 2012
    Posts
    11
    Thanks holyhttp. I was putting the $ on the outside of the []. Thanks also for the y reminder.

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