Small hotfix on convertRomanToArabic and contrary
This commit is contained in:
parent
7b66463c73
commit
3780269dd3
@ -8,7 +8,7 @@
|
||||
<div class="container">
|
||||
<div class="row pb-5">
|
||||
<h1>Bienvenue sur <span class="important">FunctionProject</span> <i class="fas fa-file-code"></i></h1>
|
||||
<p class="pt-4 mx-auto"><a href="./views/function-list.php">Liste de Mini-programme</a> permettant de <b>savoir la météo</b>, générer un <b>nombre aléatoire</b>, etc.</p>
|
||||
<p class="pt-4 mx-auto"><a href="/views/function-list.php">Liste de Mini-programme</a> permettant de <a href="/views/function-views/weatherRequest.php">savoir la météo</a>, générer un <a href="/views/function-views/randomNumber.php">nombre aléatoire</a>, etc.</p>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-6 pb-4">
|
||||
|
@ -338,7 +338,11 @@ function convertArabicToRoman(nombre) {
|
||||
extraireChiffreRomain(correspondance[0], correspondance[1]);
|
||||
})
|
||||
|
||||
return chiffresRomains;
|
||||
if (chiffresRomains === '') {
|
||||
return messageError;
|
||||
} else {
|
||||
return chiffresRomains;
|
||||
}
|
||||
}
|
||||
|
||||
// Convertis un nombre romain en nombre arabe
|
||||
|
@ -224,8 +224,13 @@ $(function () {
|
||||
$('.results').html(emptyMessageError);
|
||||
}
|
||||
else if (!isNaN(parseInt(numbersValue)) && convertNumberType === "Nombre Romain") {
|
||||
let result = convertArabicToRoman(parseInt(numbersValue.replace(/\s/g,'')));
|
||||
$('.results').html(`<b>${formatNumberResult(numbersValue.replace(/\s/g,''))}</b> s'écrit <b>${result}</b> en chiffres romains.`);
|
||||
let result = convertArabicToRoman(parseInt(numbersValue.replace(/\s/g,'')));
|
||||
let numbersValueFormat = formatNumberResult(numbersValue.replace(/\s/g,''));
|
||||
if (numbersValueFormat === messageError || result === messageError) {
|
||||
$('.results').html(messageError);
|
||||
} else {
|
||||
$('.results').html(`<b>${numbersValueFormat}</b> s'écrit <b>${result}</b> en chiffres romains.`);
|
||||
}
|
||||
}
|
||||
else if (convertNumberType === "Nombre Arabe") {
|
||||
if (!isNaN(parseInt(numbersValue))) {
|
||||
@ -233,7 +238,11 @@ $(function () {
|
||||
} else {
|
||||
numbersValue = numbersValue.toUpperCase();
|
||||
let result = convertRomanToArabic(numbersValue);
|
||||
$('.results').html(`<b>${numbersValue}</b> s'écrit <b>${result}</b> en chiffres arabes.`);
|
||||
if (result === 0) {
|
||||
$('.results').html(messageError);
|
||||
} else {
|
||||
$('.results').html(`<b>${numbersValue}</b> s'écrit <b>${result}</b> en chiffres arabes.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
Reference in New Issue
Block a user