Function - debutante [Résolu]
Résolu
nina29000
Messages postés
3
Date d'inscription
Statut
Membre
Dernière intervention
-
nina29000 Messages postés 3 Date d'inscription Statut Membre Dernière intervention -
nina29000 Messages postés 3 Date d'inscription Statut Membre Dernière intervention -
salut a tous,
je commence en javascript avec l'idée de faire un petit jeux d'anagramme et dés le début je bloque, lol.
voici mon code :
//déclartion variables
var tabMot, motChoisi;
//tableau de mot + syllabes
tabMot = [
["champignon", "cham", "pi", "gnon"],
["parapluie", "pa", "ra", "pluie"],
["telephone", "te", "le", "pho", "ne"]
];
// choix aléatoire d'un mot
function choisirMot(){
motChoisi = Math.floor((Math.random() * tabMot.length));
document.write(tabMot[motChoisi][0]);
return motChoisi;
}
// affichage syllabe
function afficheSyllabe() {
for (i = 1; i < tabMot[motChoisi].length; i++) {
document.write(tabMot[motChoisi][i]);
}
}
choisirMot();
afficheSyllabe();
j'obtiens bien le mot choisi aléatoirement. mais pas la liste de syllabes. J'ai surement un problème de portée de mes variables ????? un petite explication serait sympathique. merci
je commence en javascript avec l'idée de faire un petit jeux d'anagramme et dés le début je bloque, lol.
voici mon code :
//déclartion variables
var tabMot, motChoisi;
//tableau de mot + syllabes
tabMot = [
["champignon", "cham", "pi", "gnon"],
["parapluie", "pa", "ra", "pluie"],
["telephone", "te", "le", "pho", "ne"]
];
// choix aléatoire d'un mot
function choisirMot(){
motChoisi = Math.floor((Math.random() * tabMot.length));
document.write(tabMot[motChoisi][0]);
return motChoisi;
}
// affichage syllabe
function afficheSyllabe() {
for (i = 1; i < tabMot[motChoisi].length; i++) {
document.write(tabMot[motChoisi][i]);
}
}
choisirMot();
afficheSyllabe();
j'obtiens bien le mot choisi aléatoirement. mais pas la liste de syllabes. J'ai surement un problème de portée de mes variables ????? un petite explication serait sympathique. merci
A voir également:
- Function - debutante [Résolu]
- (Function(){css.removeclass(document.body,%20'profile_two_columns'); tab_controller.changepage("photos");})() ✓ - Forum Facebook
- Problème curseur souris incontrolable résolu - Forum Virus
- Souris incontrôlable temporairement à chaque démarrage ✓ - Forum Windows 10
- Function at 0x python ✓ - Forum Python
- Function mafonction et $('body').on('click', function() { ✓ - Forum Javascript