abracadabraPDF › Forums › PDF – Général › Raccourcir un script › Répondre à : Raccourcir un script

Essaye ça (chez moi ça fonctionne), l’idée c’est ce qu’il y a un doublon ou une association interdite on relance la fonction :
function generLettres() {
function generateRandomLetter() {
var randomValue = Math.random();
var randomCode = 65 + Math.floor(randomValue * 26);
return String.fromCharCode(randomCode);
}
var pointA = generateRandomLetter();
var pointB = generateRandomLetter();
var pointC = generateRandomLetter();
var str = pointA + pointB + pointC;
console.println("pointsABC: " + pointA + pointB + pointC);
if (pointA === pointB || pointA === pointC || pointB === pointC) {generLettres();} // dédoublonage
else if ((/PS|PC|FN|RN|FO|LR|PD|PQ|WC|GPT|PT/.test(str))) {generLettres();} // associations interdites
}
generLettres();