Random Word Generator - Blan_Hippo


SUBMITTED BY: Guest

DATE: March 9, 2014, 3:09 p.m.

FORMAT: PHP

SIZE: 857 Bytes

HITS: 910

  1. /*
  2. Just to say, this will only generate random letters and make them into a word
  3. Have fun with the code and i will see you in my next code
  4. - Blan_Hippo
  5. */
  6. function createRandomWord(length) {
  7. var consonants = 'bcdfghjklmnpqrstvwxyz',
  8. vowels = 'aeiou',
  9. rand = function(limit) {
  10. return Math.floor(Math.random()*limit);
  11. },
  12. i, word='', length = parseInt(length,10),
  13. consonants = consonants.split(''),
  14. vowels = vowels.split('');
  15. for (i=0;i<length/2;i++) {
  16. var randConsonant = consonants[rand(consonants.length)],
  17. randVowel = vowels[rand(vowels.length)];
  18. word += (i===0) ? randConsonant.toUpperCase() : randConsonant;
  19. word += i*2<length-1 ? randVowel : '';
  20. }
  21. return word;
  22. }

comments powered by Disqus