Ad

Changes include fixing the accents feature to always include only one accent in a random position.

Code
Diff
  • const accents = 'áéíóú',
          chars = 'abcdefghijklmnopqrstuvwxyz',
          a = 'bcdfghijklmnpqrstuvwxyzñ',
          b = 'aeilorsuy',
          c = 'aeioruhtlkkkkkkkkk',
          d = 'aeiourldns',
          e = 'abcdefyrnsltmpxizñ',
          f = 'aeiouylrf',
          g = 'aeiouhrlmns',
          h = 'aeiourlt',
          i = 'encstoadlmvzrgfrtpbkñ',
          j = 'uaoei',
          k = 'eiaolunyhsrw',
          l = 'eiayoug',
          m = 'aeiouypb',
          n = 'aeiouytgdcsn',
          o = 'abcdefnruplsmtzñ',
          p = 'rehaoilhtusp',
          q = 'u',
          r = 'aeioutymscdrnpb',
          s = 'etshaicupomlynk',
          t = 'eiraohuytlar',
          u = 'bcdfghnslrmtiaepzñ',
          v = 'eiaour',
          w = 'aeiouyhrnls',
          x = 'aeiouytcpl',
          y = 'elstacpnm',
          z = 'eaioyuz',
          ñ = 'aeiou';
    
    function rng (doAccents = true, min = 4, max = 8, length = Math.floor(Math.random() * (max - min + 1)) + min, firstChar = chars[Math.floor(Math.random() * chars.length)]) {
      let out = [];
      
      for (let index = 0; index < length; index++) {
        if (index == 0) {
          out.push(firstChar);
        } else {
          out.push(eval(out[index-1])[Math.floor(Math.random() * eval(out[index-1]).length)]);
        }
      }
      
      if (doAccents) {
        out = addAccents(out);
      }
      
      if (out[out.length-1] == "ñ") {
        out.push(ñ[Math.floor(Math.random() * ñ.length)]);
      }
      
      return out.join('');
    }
    
    function addAccents(arr) {
      let hasAccent = false;
      let outVowels = arr.filter(a => ñ.includes(a));
      let lastVowel = outVowels[outVowels.length-1];
      
      for (let i = 0; i < arr.length; i++) {
        let char = arr[i];
        let newChar;
        
        if (Math.random() >= 0.5 && !hasAccent && ñ.includes(char)) {
          newChar = accents[ñ.indexOf(char)];
          hasAccent = true;
        } else if (lastVowel == char && !hasAccent) {
          newChar = accents[ñ.indexOf(char)];
          hasAccent = true;
        }
        
        arr[i] = newChar || char;
      }
      return arr;
    }
    
    for(let i = 0; i < 10; i++) {
      console.log(rng(true, 5, 6));
      console.log("");
      console.log(rng(false, 4, 8));
      console.log("");
    }
    
    // good names: garnguck, lemock, wemee, yermpoo, jelifyeshi, vazaji, zufazi, dupunt, trythluid
    
    /* more good names:
      elóra, yáddro, lezíe, janeño, bahúz, gouñuña,
      volgrad, flizz, tunck, vorag, sylem, kitala, vunos, jaith, qumor, henup, ornda, zilep, cantadu, gromu, lodley
    */
    
    
    • /*
    • Changes include adding `accents` and the `ñ`.
    • I also added `min` and `max` as parameters.
    • */
    • const accents = 'áéíóú',
    • chars = 'abcdefghijklmnopqrstuvwxyz',
    • a = 'bcdfghijklmnpqrstuvwxyzñ',
    • b = 'aeilorsuy',
    • c = 'aeioruhtlkkkkkkkkk',
    • d = 'aeiourldns',
    • e = 'abcdefyrnsltmpxizñ',
    • f = 'aeiouylrf',
    • g = 'aeiouhrlmns',
    • h = 'aeiourlt',
    • i = 'encstoadlmvzrgfrtpbkñ',
    • j = 'uaoei',
    • k = 'eiaolunyhsrw',
    • l = 'eiayoug',
    • m = 'aeiouypb',
    • n = 'aeiouytgdcsn',
    • o = 'abcdefnruplsmtzñ',
    • p = 'rehaoilhtusp',
    • q = 'u',
    • r = 'aeioutymscdrnpb',
    • s = 'etshaicupomlynk',
    • t = 'eiraohuytlar',
    • u = 'bcdfghnslrmtiaepzñ',
    • v = 'eiaour',
    • w = 'aeiouyhrnls',
    • x = 'aeiouytcpl',
    • y = 'elstacpnm',
    • z = 'eaioyuz',
    • ñ = 'aeiou';
    • function rng (doAccents = true, min = 4, max = 8, length = Math.floor(Math.random() * (max - min + 1)) + min, firstChar = chars[Math.floor(Math.random() * chars.length)]) {
    • let out = [];
    • for (let index = 0; index < length; index++) {
    • if (index == 0) {
    • out.push(firstChar);
    • } else {
    • out.push(eval(out[index-1])[Math.floor(Math.random() * eval(out[index-1]).length)]);
    • }
    • }
    • if (doAccents) {
    • let hasAccent = false;
    • out = out.map(char => {
    • let newChar;
    • if (Math.floor(Math.random() * 10) >= 5) {
    • newChar = ñ.includes(char) && !hasAccent ? accents[ñ.indexOf(char)] : char;
    • hasAccent = true;
    • }
    • return newChar || char;
    • });
    • out = addAccents(out);
    • }
    • if (out[out.length-1] == "ñ") {
    • out.push(ñ[Math.floor(Math.random() * ñ.length)]);
    • }
    • return out.join('');
    • }
    • function addAccents(arr) {
    • let hasAccent = false;
    • let outVowels = arr.filter(a => ñ.includes(a));
    • let lastVowel = outVowels[outVowels.length-1];
    • for (let i = 0; i < arr.length; i++) {
    • let char = arr[i];
    • let newChar;
    • if (Math.random() >= 0.5 && !hasAccent && ñ.includes(char)) {
    • newChar = accents[ñ.indexOf(char)];
    • hasAccent = true;
    • } else if (lastVowel == char && !hasAccent) {
    • newChar = accents[ñ.indexOf(char)];
    • hasAccent = true;
    • }
    • arr[i] = newChar || char;
    • }
    • return arr;
    • }
    • for(let i = 0; i < 10; i++) {
    • console.log(rng(true, 5, 6));
    • console.log("");
    • console.log(rng(false, 4, 8));
    • console.log("");
    • }
    • // good names: garnguck, lemock, wemee, yermpoo, jelifyeshi, vazaji, zufazi, dupunt, trythluid
    • /* more good names:
    • elóra, yáddro, lezíe, janeño, bahúz, gouñuña,
    • volgrad, flizz, tunck, vorag, sylem, kitala, vunos, jaith, qumor, henup, ornda, zilep, cantadu, gromu, lodley
    • */
Code
Diff
  • /*
    Changes include adding `accents` and the `ñ`.
    I also added `min` and `max` as parameters.
    */
    
    const accents = 'áéíóú',
          chars = 'abcdefghijklmnopqrstuvwxyz',
          a = 'bcdfghijklmnpqrstuvwxyzñ',
          b = 'aeilorsuy',
          c = 'aeioruhtlkkkkkkkkk',
          d = 'aeiourldns',
          e = 'abcdefyrnsltmpxizñ',
          f = 'aeiouylrf',
          g = 'aeiouhrlmns',
          h = 'aeiourlt',
          i = 'encstoadlmvzrgfrtpbkñ',
          j = 'uaoei',
          k = 'eiaolunyhsrw',
          l = 'eiayoug',
          m = 'aeiouypb',
          n = 'aeiouytgdcsn',
          o = 'abcdefnruplsmtzñ',
          p = 'rehaoilhtusp',
          q = 'u',
          r = 'aeioutymscdrnpb',
          s = 'etshaicupomlynk',
          t = 'eiraohuytlar',
          u = 'bcdfghnslrmtiaepzñ',
          v = 'eiaour',
          w = 'aeiouyhrnls',
          x = 'aeiouytcpl',
          y = 'elstacpnm',
          z = 'eaioyuz',
          ñ = 'aeiou';
    
    function rng (doAccents = true, min = 4, max = 8, length = Math.floor(Math.random() * (max - min + 1)) + min, firstChar = chars[Math.floor(Math.random() * chars.length)]) {
      let out = [];
      
      for (let index = 0; index < length; index++) {
        if (index == 0) {
          out.push(firstChar);
        } else {
          out.push(eval(out[index-1])[Math.floor(Math.random() * eval(out[index-1]).length)]);
        }
      }
      
      if (doAccents) {
        let hasAccent = false;
        out = out.map(char => {
          let newChar;
          if (Math.floor(Math.random() * 10 >= 5)) {
            newChar = ñ.includes(char) && !hasAccent ? accents[ñ.indexOf(char)] : char;
            hasAccent = true;
          }
          return newChar || char;
        });
      }
      
      if (out[out.length-1] == "ñ") {
        out.push(ñ[Math.floor(Math.random() * ñ.length)]);
      }
      
      return out.join('');
    }
    
    for(let i = 0; i < 10; i++) {
      console.log(rng(true, 5, 6));
      console.log("");
      console.log(rng(false, 4, 8));
      console.log("");
    }
    
    // good names: garnguck, lemock, wemee, yermpoo, jelifyeshi, vazaji, zufazi, dupunt, trythluid
    
    /* more good names:
      elóra, yáddro, lezíe, janeño, bahúz, gouñuña,
      volgrad, flizz, tunck, vorag, sylem, kitala, vunos, jaith, qumor, henup, ornda, zilep, cantadu, gromu, lodley
    */
    
    
    • const chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',/* 'x',*/ 'y', 'z'];
    • var a = ['b', 'c', 'd', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    • var b = ['a', 'e', 'i', 'l', 'o', 'r', 's', 'u', 'y']
    • var c = ['a', 'e', 'i', 'o', 'r', 'u', 'h', 't', 'l', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k']
    • var d = ['a', 'e', 'i', 'o', 'u', 'r', 'l', 'd', 'n', 's']
    • var e = ['a', 'b', 'c', 'd', 'e', 'f', 'y', 'r', 'n', 's', 'l', 't', 'm', 'p', 'x', 'i']
    • var f = ['a', 'e', 'i', 'o', 'u', 'y', 'l', 'r', 'f']
    • var g = ['a', 'e', 'i', 'o', 'u', 'h', 'r', 'l', 'm', 'n', 's']
    • var h = ['a', 'e', 'i', 'o', 'u', 'r', 'l', 't']
    • var i = ['e', 'n', 'c', 's', 't', 'o', 'a', 'd', 'l', 'm', 'v', 'z', 'r', 'g', 'f', 'r', 't', 'p', 'b', 'k']
    • var j = ['u', 'a', 'o', 'e', 'i']
    • var k = ['e', 'i', 'a', 'o', 'l', 'u', 'n', 'y', 'h', 's', 'r', 'w']
    • var l = ['e', 'i', 'a', 'y', 'o', 'u']
    • var m = ['a', 'e', 'i', 'o', 'u', 'y', 'p', 'b']
    • var n = ['a', 'e', 'i', 'o', 'u', 'y', 't', 'g', 'd', 'c', 's', 'n']
    • var o = ['a', 'b', 'c', 'd', 'e', 'f', 'n', 'r', 'u', 'p', 'l', 's', 'm', 't']
    • var p = ['r', 'e', 'h', 'a', 'o', 'i', 'l', 'h', 't', 'u', 's', 'p']
    • var q = ['u']
    • var r = ['a', 'e', 'i', 'o', 'u', 't', 'y', 'm', 's', 'c', 'd', 'r', 'n', 'p', 'b']
    • var s = ['e', 't', 's', 'h', 'a', 'i', 'c', 'u', 'p', 'o', 'm', 'l', 'y', 'n', 'k']
    • var t = ['e', 'i', 'r', 'a', 'o', 'h', 'u', 'y', 't', 'l']
    • var u = ['b', 'c', 'd', 'f', 'g', 'h', 'n', 's', 'l', 'r', 'm', 't', 'i', 'a', 'e', 'p']
    • var v = ['e', 'i', 'a', 'o', 'u', 'r']
    • var w = ['a', 'e', 'i', 'o', 'u', 'y', 'h', 'r', 'n', 'l', 's']
    • var x = ['a', 'e', 'i', 'o', 'u', 'y', 't', 'c', 'p', 'l']
    • var y = ['e', 'l', 's', 't', 'a', 'c', 'p', 'n', 'm']
    • var z = ['e', 'a', 'i', 'o', 'y', 'u', 'z']
    • //'a', 'e', 'i', 'o', 'u', 'y'
    • //n, (p, b);m
    • const varToString = varObj => Object.keys(varObj)[0]
    • var min = 4;
    • var max = 8;
    • function rng(length = Math.floor(Math.random() * (max - min +1)) + min,
    • firstChar = chars[Math.floor(Math.random() * chars.length)]) {
    • var out = [];
    • for(var increment = 0; increment < length; increment++){
    • if(increment == 0){
    • out.push(firstChar)
    • /*
    • Changes include adding `accents` and the `ñ`.
    • I also added `min` and `max` as parameters.
    • */
    • const accents = 'áéíóú',
    • chars = 'abcdefghijklmnopqrstuvwxyz',
    • a = 'bcdfghijklmnpqrstuvwxyzñ',
    • b = 'aeilorsuy',
    • c = 'aeioruhtlkkkkkkkkk',
    • d = 'aeiourldns',
    • e = 'abcdefyrnsltmpxizñ',
    • f = 'aeiouylrf',
    • g = 'aeiouhrlmns',
    • h = 'aeiourlt',
    • i = 'encstoadlmvzrgfrtpbkñ',
    • j = 'uaoei',
    • k = 'eiaolunyhsrw',
    • l = 'eiayoug',
    • m = 'aeiouypb',
    • n = 'aeiouytgdcsn',
    • o = 'abcdefnruplsmtzñ',
    • p = 'rehaoilhtusp',
    • q = 'u',
    • r = 'aeioutymscdrnpb',
    • s = 'etshaicupomlynk',
    • t = 'eiraohuytlar',
    • u = 'bcdfghnslrmtiaepzñ',
    • v = 'eiaour',
    • w = 'aeiouyhrnls',
    • x = 'aeiouytcpl',
    • y = 'elstacpnm',
    • z = 'eaioyuz',
    • ñ = 'aeiou';
    • function rng (doAccents = true, min = 4, max = 8, length = Math.floor(Math.random() * (max - min + 1)) + min, firstChar = chars[Math.floor(Math.random() * chars.length)]) {
    • let out = [];
    • for (let index = 0; index < length; index++) {
    • if (index == 0) {
    • out.push(firstChar);
    • } else {
    • //console.log(out[increment-1]);
    • out.push((eval(out[increment-1]))[Math.floor(Math.random() * (eval(out[increment-1])).length)]);
    • out.push(eval(out[index-1])[Math.floor(Math.random() * eval(out[index-1]).length)]);
    • }
    • }
    • return out.join('')
    • if (doAccents) {
    • let hasAccent = false;
    • out = out.map(char => {
    • let newChar;
    • if (Math.floor(Math.random() * 10 >= 5)) {
    • newChar = ñ.includes(char) && !hasAccent ? accents[ñ.indexOf(char)] : char;
    • hasAccent = true;
    • }
    • return newChar || char;
    • });
    • }
    • if (out[out.length-1] == "ñ") {
    • out.push(ñ[Math.floor(Math.random() * ñ.length)]);
    • }
    • return out.join('');
    • }
    • for(let i = 0; i < 10; i++) {
    • console.log(rng(true, 5, 6));
    • console.log("");
    • console.log(rng(false, 4, 8));
    • console.log("");
    • }
    • console.log(rng());
    • //good names: garnguck, lemock, wemee, yermpoo, jelifyeshi, vazaji, zufazi, dupunt, trythluid
    • // good names: garnguck, lemock, wemee, yermpoo, jelifyeshi, vazaji, zufazi, dupunt, trythluid
    • /* more good names:
    • elóra, yáddro, lezíe, janeño, bahúz, gouñuña,
    • volgrad, flizz, tunck, vorag, sylem, kitala, vunos, jaith, qumor, henup, ornda, zilep, cantadu, gromu, lodley
    • */