Random Word Generator - Eta_Hippo


SUBMITTED BY: Guest

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

FORMAT: PHP

SIZE: 855 Bytes

HITS: 777

  1. /*
  2. Made by Eta_Hippo
  3. Have fun. And one thing: It creates random letters and make a word out of them
  4. So the words that come out are not really real words
  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