From 61ddfa49779ad55f657782c02714fdf9dee4ac2b Mon Sep 17 00:00:00 2001 From: Divlo Date: Sun, 15 Sep 2019 09:45:20 +0200 Subject: [PATCH] Small bug fixes convertDistance --- scripts/fonctions.js | 2 +- scripts/main.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/fonctions.js b/scripts/fonctions.js index 34fd21e..26d63be 100644 --- a/scripts/fonctions.js +++ b/scripts/fonctions.js @@ -131,7 +131,7 @@ function convertDistance (firstValue, unitFirstValue, unitFinalValue) { // Conversion des longueurs : let difference = index1 - index2; let result = firstValue*Math.pow(10,difference); - let response = 'Conversion de longueur : ' + firstValue.toString() + ' ' + unitFirstValue + ' = ' + formatNumberResult(result) + ' ' + unitFinalValue; + let response = 'Conversion de longueur : ' + formatNumberResult(firstValue).toString() + ' ' + unitFirstValue + ' = ' + formatNumberResult(result) + ' ' + unitFinalValue; return response; } else diff --git a/scripts/main.js b/scripts/main.js index 73ec22a..8ca9192 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -110,7 +110,8 @@ $(function () { } else { - let result = convertDistance(parseFloat(firstValue), unitFirstValue, secondValue); + firstValue = parseFloat(firstValue.replace(/\s/g,'')); + let result = convertDistance(firstValue, unitFirstValue, secondValue); if(result === messageError) { $('.results').html(messageError);