Probleme structure fonction Javascript
Fermé
math_lo
-
10 nov. 2011 à 11:32
JooS Messages postés 2465 Date d'inscription mardi 22 janvier 2008 Statut Membre Dernière intervention 8 juin 2016 - 10 nov. 2011 à 15:10
JooS Messages postés 2465 Date d'inscription mardi 22 janvier 2008 Statut Membre Dernière intervention 8 juin 2016 - 10 nov. 2011 à 15:10
A voir également:
- Probleme structure fonction Javascript
- Telecharger javascript - Télécharger - Langages
- Fonction si et - Guide
- Javascript round ✓ - Forum Javascript
- Dans la table des matières de ce document, le chapitre 6 et ses 2 sections n'apparaissent pas. trouvez l'erreur dans la structure du document et corrigez-la. mettez à jour la table des matières. quel est le mot formé par les lettres en majuscules de la table des matières après sa mise à jour ? - Forum Word
- Fonction si avec date ✓ - Forum Excel
1 réponse
JooS
Messages postés
2465
Date d'inscription
mardi 22 janvier 2008
Statut
Membre
Dernière intervention
8 juin 2016
228
10 nov. 2011 à 15:10
10 nov. 2011 à 15:10
Salut ...
A revoir ...
function int_to_string(arg) { // Fonction pour les unités
switch (arg) {
case 1: unite = "Un"; break;
case 2: unite = "Deux"; break;
case 3: unite = "Trois"; break;
case 4: unite = "Quatre"; break;
case 5: unite = "Cinq"; break;
case 6: unite = "Six"; break;
case 7: unite = "Sept"; break;
case 8: unite = "Huit"; break;
case 9: unite = "Neuf"; break;
case 0: unite = "Zero"; break;
case 11: unite = "Onze"; break;
case 12: unite = "Douze"; break;
case 13: unite = "Treize"; break;
case 14: unite = "Quatorze"; break;
case 15: unite = "Quinze"; break;
case 16: unite = "Seize"; break;
case 17: unite = "Dix-Sept"; break;
case 18: unite = "Dix-Huit"; break;
case 19: unite = "Dix-Neuf"; break;
case 20: unite = "Vingt"; break;
case 30: unite = "Trente"; break;
case 40: unite = "Quarente"; break;
case 50: unite = "Cinquante"; break;
case 60: unite = "Soixante"; break;
case 80: unite = "Quatre-vingt"; break;
case 100: unite = "Cent"; break;
default: return false;
}
return(unite);
}
//--------------------------------------------------------------
function int2_to_string(col10, col1) {
var first, second;
if(col10 == '0') return int_to_string(parseInt(col1,10));
else if(col10 == '7') {
first = int_to_string(parseInt(60,10));
second = int_to_string(parseInt(1+col1,10));
if(col1 == '1') return first+' et '+second;
return first+'-'+second;
}
else if(col10 == '9') {
first = int_to_string(parseInt(80,10));
second = int_to_string(parseInt(1+col1,10));
if(col1 == '1') return first+' et '+second;
return first+'-'+second;
}
else {
first = int_to_string(parseInt(col10+0,10));
second = int_to_string(parseInt(col1,10));
if(col1 == '1') return first+' et '+second;
return first+'-'+second;
}
}
//--------------------------------------------------------------
function convertNumber(number) {
var col1, col10, col100;
number = parseInt(number,10);
//-----------------------------------------
var word = int_to_string(number);
if(word) return word;
//-----------------------------------------
var numberL = number+'';
if(numberL.length == 2) {
col10 = numberL[0]; // 90
col1 = numberL[1]; // 8
return int2_to_string(col10, col1);
}
else if(numberL.length == 3) { //986
col100 = numberL[0]; // 900
col10 = numberL[1]; // 80
col1 = numberL[2]; // 6
if(col100 == '1') {
return 'Cent '+int2_to_string(col10, col1);
}
else {
return int_to_string(parseInt(col100,10))+' Cents '+int2_to_string(col10, col1);
}
}
else alert(numberL.length);
}
//--------------------------------------------------------------
alert(convertNumber(prompt('Entrez un nombre : ')));
A revoir ...