🐛 FIX: Small fixes
This commit is contained in:
		| @@ -21,8 +21,8 @@ const correspondancesRomainArabe = [ | ||||
|  | ||||
| /**  | ||||
|  * @description Convertis un nombre arabe en nombre romain. | ||||
|  * @param {Number} nombre - Le nombre arabe à convertir | ||||
|  * @returns {String} | ||||
|  * @param {number} nombre - Le nombre arabe à convertir | ||||
|  * @returns {string} | ||||
|  * @examples convertArabicToRoman(24) → 'XXIV' | ||||
|  */ | ||||
| function convertArabicToRoman(nombre) { | ||||
| @@ -45,21 +45,21 @@ function convertArabicToRoman(nombre) { | ||||
|  | ||||
| /**  | ||||
|  * @description Convertis un nombre romain en nombre arabe. | ||||
|  * @param {String} str - Le nombre romain à convertir | ||||
|  * @returns {Number} | ||||
|  * @examples convertRomanToArabic('XXIV') → 24 | ||||
|  * @param {string} string - Le nombre romain à convertir | ||||
|  * @return {number} | ||||
|  * @example convertRomanToArabic('XXIV') → 24 | ||||
|  */ | ||||
| function convertRomanToArabic(str) { | ||||
| function convertRomanToArabic(string) { | ||||
|     let result = 0; | ||||
|     for (let i = 0; i < correspondancesRomainArabe.length; i++) { | ||||
|         while (str.indexOf(correspondancesRomainArabe[i][1]) === 0) { | ||||
|     correspondancesRomainArabe.forEach((correspondance) => {         | ||||
|         while (string.indexOf(correspondance[1]) === 0) { | ||||
|             // Ajout de la valeur décimale au résultat | ||||
|             result += correspondancesRomainArabe[i][0]; | ||||
|             result += correspondance[0]; | ||||
|             // Supprimer la lettre romaine correspondante du début | ||||
|             str = str.replace(correspondancesRomainArabe[i][1],''); | ||||
|             string = string.replace(correspondance[1], ''); | ||||
|         } | ||||
|     } | ||||
|     if (str != '') { | ||||
|     }); | ||||
|     if (string != '') { | ||||
|         result = 0; | ||||
|     } | ||||
|     return result; | ||||
|   | ||||
| @@ -16,7 +16,8 @@ function getRandomArrayElement(array) { | ||||
|     return array[randomNumber(0, array.length - 1)]; | ||||
| } | ||||
|  | ||||
| async function getAmazonProductList(url) { | ||||
| async function getAmazonProductList(subject) { | ||||
|     const url       = `https://www.amazon.fr/s?k=${subject}`; | ||||
|     const Nightmare = require('nightmare')(); | ||||
|     return await Nightmare.goto(url) | ||||
|         .wait('.s-result-item') | ||||
| @@ -33,7 +34,7 @@ async function getAmazonProductList(url) { | ||||
|                         image: productImage["src"], | ||||
|                         price: Number(originalPrice.replace(",", ".").replace(" ", "")) | ||||
|                     }); | ||||
|                 } catch (error) { | ||||
|                 } catch (_error) { | ||||
|                     continue; | ||||
|                 } | ||||
|             } | ||||
| @@ -44,7 +45,7 @@ async function getAmazonProductList(url) { | ||||
|  | ||||
| module.exports = rightPriceOutput = async ({ res }, _argsObject) => { | ||||
|     const subject       = getRandomArrayElement(subjectList); | ||||
|     const productsList  = await getAmazonProductList(`https://www.amazon.fr/s?k=${subject}`); | ||||
|     const productsList  = await getAmazonProductList(subject); | ||||
|     const randomProduct = getRandomArrayElement(productsList); | ||||
|     return res.status(200).json({ subject, ...randomProduct }); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user