www.webdeveloper.com
Results 1 to 6 of 6

Thread: need help - Ten Simple Javascript Exercises

  1. #1
    Join Date
    May 2009
    Posts
    1

    need help - Ten Simple Javascript Exercises


  2. #2
    Join Date
    Mar 2009
    Location
    Yorkshire
    Posts
    266
    So you want us to do this for you??

  3. #3
    Join Date
    Aug 2008
    Posts
    22
    Holy cow! I totally did one of these without even looking at this post.
    Code:
    function findType(chara){
    var vowels=new Array();
    vowels[0]='a';
    vowels[1]='e';
    vowels[2]='i';
    vowels[3]='o';
    vowels[4]='u';
    vowels[5]='y';
    for(i=0;i<6;i++){
    if(chara==vowels[i]){
    alert('Vowel present.');
    }
    }
    }

  4. #4
    Join Date
    May 2009
    Posts
    150
    Well he's still not said what it is he wants, however:

    Code:
    function isVowel(chara)
    {
    	// Checks if the first character is a vowel
    	// If the string is longer than 1 it makes no difference
    	// Case insensitive
    	return chara.test(/^[aeiou]/i);
    }

  5. #5
    Join Date
    Jun 2007
    Posts
    667
    Quote Originally Posted by Y_Less View Post
    Code:
    function isVowel(chara)
    {
    	// Checks if the first character is a vowel
    	// If the string is longer than 1 it makes no difference
    	// Case insensitive
    	return chara.test(/^[aeiou]/i);
    }
    Code:
    return /[aeiou]/i.test( chara );

  6. #6
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,278
    Code:
    String.prototype.isVowel = function () {return /[aeiou]/i.test(this) || (Math.random() > 0.5 && /y/i.test (this))}
    
    alert ('y'.isVowel());
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

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