/* categories */
INSERT INTO `categories` (`id`, `name`, `color`, `createdAt`, `updatedAt`) VALUES
(1, '✨ Utilitaires', '#720fc0', '2020-03-20 00:00:00', '2020-03-20 00:00:00'),
(2, '💻 Algorithmes', '#0a4c82', '2020-03-20 00:00:00', '2020-03-20 00:00:00'),
(3, '🕹️ Jeux', '#a10b0b', '2020-03-20 00:00:00', '2020-03-20 00:00:00'),
(4, '📝 Divers', '#333434', '2020-03-20 00:00:00', '2020-03-20 00:00:00');

/* functions */
INSERT INTO `functions` (`id`, `title`, `slug`, `description`, `image`, `type`, `article`, `utilizationForm`, `isOnline`, `createdAt`, `updatedAt`, `categorieId`) VALUES
(1, 'Météo', 'weatherRequest', 'Affiche la météo et l\'heure locale.', '/images/functions/weatherRequest.png', 'form', '<p>Pour une meilleure précision, je recommande de préciser le pays de la ville. Il faut rentrer le nom anglais de la ville (s\"il est différent qu\"en français).</p><p>Exemples : Paris, FR - London, UK - Moscow, RU - etc.</p><p>La météo est récupérée grâce à l\"API&nbsp;<a rel=\"noopener noreferrer\" target=\"_blank\" href=\"https://openweathermap.org/\">openweathermap.org</a>, une simple requête GET.</p>', '[{\"name\": \"cityName\", \"type\": \"text\", \"label\": \"Entrez le nom d\'une ville :\", \"placeholder\": \"(e.g : Paris, FR)\"}]', 1, '2019-08-16 00:00:00', '2020-05-08 13:43:26', 1),
(2, 'Nombre aléatoire', 'randomNumber', 'Génère un nombre aléatoire entre un minimum inclus et un maximum inclus.', '/images/functions/randomNumber.png', 'form', '<p>Simple fonction très utile dans de nombreux cas, qui permet de générer un nombre aléatoire entre un nombre minimum et un nombre maximum :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">randomNumber</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">max</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #4ec9b0;\">Math</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">floor</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #4ec9b0;\">Math</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">random</span><span style=\"color: #d4d4d4;\">()&nbsp;*&nbsp;(</span><span style=\"color: #9cdcfe;\">max</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">&nbsp;+</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">))&nbsp;+&nbsp;</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div>', '[{\"name\": \"min\", \"type\": \"integer\", \"label\": \"Entrez la valeur minimale :\", \"placeholder\": \"(e.g : 1)\"}, {\"name\": \"max\", \"type\": \"integer\", \"label\": \"Entrez la valeur maximale :\", \"placeholder\": \"(e.g : 100)\"}]', 1, '2019-08-16 00:00:00', '2020-05-08 13:23:22', 2),
(3, 'Quel âge avez-vous ?', 'calculateAge', 'Calcule l\'âge selon la date de naissance.', '/images/functions/calculateAge.png', 'form', '<p>Grâce à la librairie \"Moment.js\" c\"est très simple (le code s\'explique tout seul, je pense) :&nbsp;</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">calculateAge</span><span style=\"color: #d4d4d4;\">({&nbsp;</span><span style=\"color: #9cdcfe;\">birthDateDay</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">birthDateMonth</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">birthDateYear</span><span style=\"color: #d4d4d4;\">&nbsp;})&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">currentDate</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #569cd6;\">new</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #4ec9b0;\">Date</span><span style=\"color: #d4d4d4;\">();</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">day</span><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">currentDate</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">getDate</span><span style=\"color: #d4d4d4;\">();</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">month</span><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">currentDate</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">getMonth</span><span style=\"color: #d4d4d4;\">();</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">currentDateMoment</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #dcdcaa;\">moment</span><span style=\"color: #d4d4d4;\">([</span><span style=\"color: #9cdcfe;\">currentDate</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">getFullYear</span><span style=\"color: #d4d4d4;\">(),&nbsp;</span><span style=\"color: #9cdcfe;\">month</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">day</span><span style=\"color: #d4d4d4;\">]);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">birthDateMoment</span><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;=&nbsp;</span><span style=\"color: #dcdcaa;\">moment</span><span style=\"color: #d4d4d4;\">([</span><span style=\"color: #9cdcfe;\">birthDateYear</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">birthDateMonth</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">birthDateDay</span><span style=\"color: #d4d4d4;\">]);</span></div><br><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #6a9955;\">//&nbsp;Calcule&nbsp;l\'âge&nbsp;-&nbsp;Moment.js</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">ageYears</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">currentDateMoment</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">diff</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">birthDateMoment</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\'year\'</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">birthDateMoment</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">add</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">ageYears</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\'years\'</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">ageMonths</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">currentDateMoment</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">diff</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">birthDateMoment</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\'months\'</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">birthDateMoment</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">add</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">ageMonths</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\'months\'</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">ageDays</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">currentDateMoment</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">diff</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">birthDateMoment</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\'days\'</span><span style=\"color: #d4d4d4;\">);</span></div><br><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">isBirthday</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;(</span><span style=\"color: #9cdcfe;\">birthDateDay</span><span style=\"color: #d4d4d4;\">&nbsp;===&nbsp;</span><span style=\"color: #9cdcfe;\">day</span><span style=\"color: #d4d4d4;\">&nbsp;&amp;&amp;&nbsp;</span><span style=\"color: #9cdcfe;\">birthDateMonth</span><span style=\"color: #d4d4d4;\">&nbsp;===&nbsp;</span><span style=\"color: #9cdcfe;\">month</span><span style=\"color: #d4d4d4;\">);&nbsp;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;{&nbsp;</span><span style=\"color: #9cdcfe;\">ageYears</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">ageMonths</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">ageDays</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">isBirthday</span><span style=\"color: #d4d4d4;\">&nbsp;};</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div>', '[{\"name\": \"birthDate\", \"type\": \"calendar\", \"label\": \"Entrez la date de naissance au format (dd/mm/yyyy) :\", \"placeholder\": \"Sélectionnez une date\"}]', 1, '2019-08-16 00:00:00', '2020-05-10 11:24:02', 1),
(4, 'Conversion de Température', 'convertTemperature', 'Convertis des Degré Celsius en Degré Fahrenheit et l\'inverse aussi.', '/images/functions/convertTemperature.png', 'form', '<p>Cette fonction n\"est pas trop intéressante, c\"est juste de l\"application de formules :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Convertis&nbsp;des&nbsp;°C&nbsp;en&nbsp;°F&nbsp;et&nbsp;l\'inverse&nbsp;aussi.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{number}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">degree</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Nombre&nbsp;de&nbsp;degrès</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{string}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">unit</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Unité&nbsp;du&nbsp;nombre&nbsp;(°C&nbsp;ou&nbsp;°F)&nbsp;après&nbsp;conversion</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{object}</span><span style=\"color: #6a9955;\">&nbsp;le&nbsp;nombre&nbsp;résultat</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@examples</span><span style=\"color: #6a9955;\">&nbsp;convertTemperature(23,&nbsp;\'°F\')&nbsp;→&nbsp;73.4</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">convertTemperature</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">degree</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">unit</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">temperatureValue</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">if</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">unit</span><span style=\"color: #d4d4d4;\">&nbsp;===&nbsp;</span><span style=\"color: #ce9178;\">\"°C\"</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">temperatureValue</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;(</span><span style=\"color: #9cdcfe;\">degree</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #b5cea8;\">32</span><span style=\"color: #d4d4d4;\">)&nbsp;*&nbsp;</span><span style=\"color: #b5cea8;\">5</span><span style=\"color: #d4d4d4;\">/</span><span style=\"color: #b5cea8;\">9</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">else</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #c586c0;\">if</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">unit</span><span style=\"color: #d4d4d4;\">&nbsp;===&nbsp;</span><span style=\"color: #ce9178;\">\"°F\"</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">temperatureValue</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;((</span><span style=\"color: #9cdcfe;\">degree</span><span style=\"color: #d4d4d4;\">&nbsp;*&nbsp;</span><span style=\"color: #b5cea8;\">9</span><span style=\"color: #d4d4d4;\">/</span><span style=\"color: #b5cea8;\">5</span><span style=\"color: #d4d4d4;\">)&nbsp;+&nbsp;</span><span style=\"color: #b5cea8;\">32</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">temperatureValue</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}&nbsp;</span></div></div>', '[{\"name\": \"degree\", \"type\": \"float\", \"label\": \"Entrez la température\", \"placeholder\": \"(e.g : 23)\"}, {\"name\": \"unitToConvert\", \"type\": \"select\", \"label\": \"Convertir en : \", \"options\": [{\"name\": \"Degré Celsius (°C)\", \"value\": \"°C\"}, {\"name\": \"Degré Fahrenheit (°F)\", \"value\": \"°F\"}], \"placeholder\": \"\"}]', 1, '2019-08-16 00:00:00', '2020-05-08 13:34:26', 1),
(5, 'Conversion de Distance', 'convertDistance', 'Convertis la longueur (distance) avec les unités allant de picomètre au Téramètre.', '/images/functions/convertDistance.png', 'form', '<p>Pour cette fonction on a un tableau de référence allant de pm à Tm :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">correspondancesDistance</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;[</span><span style=\"color: #ce9178;\">\"pm\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"nm\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"µm\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"mm\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"cm\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"dm\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"m\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"dam\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"hm\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"km\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"Mm\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"Gm\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">null</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"Tm\"</span><span style=\"color: #d4d4d4;\">];</span></div></div><p>Puis grâce à la différence des index des unités, on peut multiplier la valeur initiale par 10 puissance la différence :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Convertis&nbsp;la&nbsp;longueur&nbsp;(distance)&nbsp;avec&nbsp;les&nbsp;unités&nbsp;allant&nbsp;de&nbsp;picomètre&nbsp;au&nbsp;Téramètre.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{number}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">firstValue</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;que&nbsp;vous&nbsp;voulez&nbsp;convertir</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{string}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">unitFirstValue</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;L\'unité&nbsp;du&nbsp;nombre&nbsp;que&nbsp;vous&nbsp;voulez&nbsp;convertir</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{string}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">unitFinalValue</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;&nbsp;L\'unité&nbsp;de&nbsp;votre&nbsp;nombre&nbsp;après&nbsp;la&nbsp;conversion</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{number}</span><span style=\"color: #6a9955;\">&nbsp;→ le&nbsp;nombre&nbsp;résultat</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@examples</span><span style=\"color: #6a9955;\">&nbsp;convertDistance(500,&nbsp;\'cm\',&nbsp;\'m\')&nbsp;→&nbsp;5</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">convertDistance</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">firstValue</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">unitFirstValue</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">unitFinalValue</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">index1</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">correspondancesDistance</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">indexOf</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">unitFirstValue</span><span style=\"color: #d4d4d4;\">);&nbsp;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">index2</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">correspondancesDistance</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">indexOf</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">unitFinalValue</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">difference</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">index1</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #9cdcfe;\">index2</span><span style=\"color: #d4d4d4;\">;&nbsp;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">firstValue</span><span style=\"color: #d4d4d4;\">&nbsp;*&nbsp;</span><span style=\"color: #4ec9b0;\">Math</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">pow</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #b5cea8;\">10</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">difference</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div>', '[{\"name\": \"number\", \"type\": \"float\", \"label\": \"Entrez la distance que vous voulez convertir :\", \"placeholder\": \"(e.g : 50)\"}, {\"name\": \"numberUnit\", \"type\": \"select\", \"label\": \"L\'unité du nombre que vous voulez convertir : \", \"options\": [{\"name\": \"Picomètre (pm)\", \"value\": \"pm\"}, {\"name\": \"Nanomètre (nm)\", \"value\": \"nm\"}, {\"name\": \"Micromètre (µm)\", \"value\": \"µm\"}, {\"name\": \"Millimètre (mm)\", \"value\": \"mm\"}, {\"name\": \"Centimètre (cm)\", \"value\": \"cm\"}, {\"name\": \"Décimètre (dm)\", \"value\": \"dm\"}, {\"name\": \"Mètre (m)\", \"value\": \"m\"}, {\"name\": \"Décamètre (dam)\", \"value\": \"dam\"}, {\"name\": \"Hectomètre (hm)\", \"value\": \"hm\"}, {\"name\": \"Kilomètre (km)\", \"value\": \"km\"}, {\"name\": \"Mégamètre (Mm)\", \"value\": \"Mm\"}, {\"name\": \"Gigamètre (Gm)\", \"value\": \"Gm\"}, {\"name\": \"Téramètre (Tm)\", \"value\": \"Tm\"}], \"placeholder\": \"\"}, {\"name\": \"finalUnit\", \"type\": \"select\", \"label\": \"Choisissez l\'unité que vous voulez avoir après conversion :\", \"options\": [{\"name\": \"Picomètre (pm)\", \"value\": \"pm\"}, {\"name\": \"Nanomètre (nm)\", \"value\": \"nm\"}, {\"name\": \"Micromètre (µm)\", \"value\": \"µm\"}, {\"name\": \"Millimètre (mm)\", \"value\": \"mm\"}, {\"name\": \"Centimètre (cm)\", \"value\": \"cm\"}, {\"name\": \"Décimètre (dm)\", \"value\": \"dm\"}, {\"name\": \"Mètre (m)\", \"value\": \"m\"}, {\"name\": \"Décamètre (dam)\", \"value\": \"dam\"}, {\"name\": \"Hectomètre (hm)\", \"value\": \"hm\"}, {\"name\": \"Kilomètre (km)\", \"value\": \"km\"}, {\"name\": \"Mégamètre (Mm)\", \"value\": \"Mm\"}, {\"name\": \"Gigamètre (Gm)\", \"value\": \"Gm\"}, {\"name\": \"Téramètre (Tm)\", \"value\": \"Tm\"}], \"placeholder\": \"\"}]', 1, '2019-08-16 00:00:00', '2020-05-08 13:30:46', 1),
(6, 'Générateur de citations', 'randomQuote', 'Génère aléatoirement une citation ou un proverbe.', '/images/functions/randomQuote.png', 'page', '<p>Même principe que la fonction randomNumber, on a une liste de citation contenu dans un tableau et on sélectionne un index au hasard dans ce tableau grâce à la fonction randomNumber, par exemple :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">randomNumber</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">max</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #4ec9b0;\">Math</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">floor</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #4ec9b0;\">Math</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">random</span><span style=\"color: #d4d4d4;\">()&nbsp;*&nbsp;(</span><span style=\"color: #9cdcfe;\">max</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">&nbsp;+</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">))&nbsp;+&nbsp;</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div><div><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">quotes</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;[</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">quote:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #ce9178;\">\"Deux&nbsp;choses&nbsp;sont&nbsp;infinies:&nbsp;l\'univers&nbsp;et&nbsp;la&nbsp;bêtise&nbsp;humaine;&nbsp;et&nbsp;je&nbsp;ne&nbsp;suis&nbsp;pas&nbsp;sûr&nbsp;de&nbsp;l\'univers.\"</span><span style=\"color: #d4d4d4;\">,</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">source:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #ce9178;\">\"Albert&nbsp;Einstein\"</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">quote:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #ce9178;\">\"Exige&nbsp;beaucoup&nbsp;de&nbsp;toi-même&nbsp;et&nbsp;attends&nbsp;peu&nbsp;des&nbsp;autres.&nbsp;Ainsi&nbsp;beaucoup&nbsp;d\'ennuis&nbsp;te&nbsp;seront&nbsp;épargnés.\"</span><span style=\"color: #d4d4d4;\">,</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">source:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #ce9178;\">\"Confucius\"</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">];</span></div><div><span style=\"color: #4ec9b0;\">console</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">log</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">quotes</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #dcdcaa;\">randomNumber</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">quotes</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">)]);</span></div></div>', NULL, 1, '2019-09-13 00:00:00', '2020-05-08 13:52:57', 1),
(7, 'Conversion de devise', 'convertCurrency', 'Convertis une valeur dans une devise dans une autre devise.', '/images/functions/convertCurrency.png', 'form', '<p>Les taux de changes sont récupérée grâce à l\"api : <a target=\"_blank\" href=\"https://api.exchangeratesapi.io\">https://api.exchangeratesapi.io</a></p><p>Pas plus compliqué qu\'une simple requête GET.</p>', '[{\"name\": \"number\", \"type\": \"float\", \"label\": \"Entrez le nombre à convertir :\", \"placeholder\": \"(e.g : 50)\"}, {\"name\": \"baseCurrency\", \"type\": \"select\", \"label\": \"La devise du nombre que vous voulez convertir :\", \"options\": [{\"name\": \"Euro (€) - EUR\", \"value\": \"EUR\"}, {\"name\": \"Livre sterling (£) - GBP\", \"value\": \"GBP\"}, {\"name\": \"Dollar Américain ($) - USD\", \"value\": \"USD\"}, {\"name\": \"Dollar Canadien ($) - CAD\", \"value\": \"CAD\"}, {\"name\": \"Dollar Australien ($) - AUD\", \"value\": \"AUD\"}, {\"name\": \"Peso Mexicain ($) - MXN\", \"value\": \"MXN\"}, {\"name\": \"Franc Suisse (Fr) - CHF\", \"value\": \"CHF\"}, {\"name\": \"Rouble Russe (₽) - RUB\", \"value\": \"RUB\"}, {\"name\": \"Réal brésilien (R$) - BRL\", \"value\": \"BRL\"}, {\"name\": \"Yen (¥) - JPY\", \"value\": \"JPY\"}]}, {\"name\": \"finalCurrency\", \"type\": \"select\", \"label\": \"Choisissez la devise que voulez avoir après conversion :\", \"options\": [{\"name\": \"Livre sterling (£) - GBP\", \"value\": \"GBP\"}, {\"name\": \"Dollar Américain ($) - USD\", \"value\": \"USD\"}, {\"name\": \"Dollar Canadien ($) - CAD\", \"value\": \"CAD\"}, {\"name\": \"Dollar Australien ($) - AUD\", \"value\": \"AUD\"}, {\"name\": \"Peso Mexicain ($) - MXN\", \"value\": \"MXN\"}, {\"name\": \"Franc Suisse (Fr) - CHF\", \"value\": \"CHF\"}, {\"name\": \"Rouble Russe (₽) - RUB\", \"value\": \"RUB\"}, {\"name\": \"Réal brésilien (R$) - BRL\", \"value\": \"BRL\"}, {\"name\": \"Yen (¥) - JPY\", \"value\": \"JPY\"}, {\"name\": \"Euro (€) - EUR\", \"value\": \"EUR\"}]}]', 1, '2019-09-13 00:00:00', '2020-05-08 13:47:42', 1),
(8, 'Conversion des Encodages de caractères', 'convertEncoding', 'Convertis des nombres de différentes bases et convertis en UTF-8.', '/images/functions/convertEncoding.png', 'form', '<p>Je vais vous montrer le code de quelques fonctions (souvent le code s\'explique tout seul, j\'utilise seulement parseInt et .toString), pour voir toutes les fonctions, je vous invite à voir le code source disponible sur GitHub.<br>\n<br>\n\n\n\n\n- Convertis un nombre décimal en binaire :\n</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Convertis&nbsp;un&nbsp;nombre&nbsp;décimal&nbsp;en&nbsp;binaire.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{number}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">number</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;à&nbsp;convertir&nbsp;en&nbsp;string</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@return</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{string}</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;en&nbsp;binaire</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@example</span><span style=\"color: #6a9955;\">&nbsp;decimalToBinary(\"2\")&nbsp;→&nbsp;\"10\"</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">decimalToBinary</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">number</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">number</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">toString</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #b5cea8;\">2</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">}&nbsp;</span></div></div><p>- Convertis un nombre binaire en décimal :</p><p></p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Convertis&nbsp;un&nbsp;nombre&nbsp;binaire&nbsp;en&nbsp;décimal.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{string}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;binaire&nbsp;à&nbsp;convertir</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{number}</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;en&nbsp;décimal&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@examples</span><span style=\"color: #6a9955;\">&nbsp;binaryToDecimal(\"10\")&nbsp;→&nbsp;2</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">binaryToDecimal</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">parseInt</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #b5cea8;\">2</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">}&nbsp;</span></div></div><p>- Convertis un nombre hexadécimal en décimal :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Convertis&nbsp;un&nbsp;nombre&nbsp;hexadécimal&nbsp;en&nbsp;décimal.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{string}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;à&nbsp;convertir</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@return</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{number}</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;en&nbsp;décimal&nbsp;soit&nbsp;en&nbsp;nombre&nbsp;ou&nbsp;soit&nbsp;en&nbsp;string&nbsp;si&nbsp;supérieur&nbsp;à&nbsp;1000&nbsp;car&nbsp;pour&nbsp;1000&nbsp;par&nbsp;exemple&nbsp;formatNumberResult&nbsp;renvoie&nbsp;\"1&nbsp;000\"</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@examples</span><span style=\"color: #6a9955;\">&nbsp;hexadecimalToDecimal(\"F\")&nbsp;→&nbsp;15</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">hexadecimalToDecimal</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">parseInt</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #b5cea8;\">16</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">}&nbsp;</span></div></div><p>- Convertis un nombre binaire en hexadécimal :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Convertis&nbsp;un&nbsp;nombre&nbsp;binaire&nbsp;en&nbsp;hexadécimal.&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{string}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;à&nbsp;convertir</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{string}</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;en&nbsp;hexadécimal</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@examples</span><span style=\"color: #6a9955;\">&nbsp;binaryToHexadecimal(\"1111\")&nbsp;→&nbsp;\"F\"</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span><span style=\"color: #d4d4d4;\">&nbsp;</span></div><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">binaryToHexadecimal</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #dcdcaa;\">parseInt</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #b5cea8;\">2</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">parseInt</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #d4d4d4;\">).</span><span style=\"color: #dcdcaa;\">toString</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #b5cea8;\">16</span><span style=\"color: #d4d4d4;\">).</span><span style=\"color: #dcdcaa;\">toUpperCase</span><span style=\"color: #d4d4d4;\">();</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div>', '[{\"name\": \"value\", \"type\": \"text\", \"label\": \"Entrez votre valeur :\", \"placeholder\": \"Votre valeur...\"}, {\"name\": \"functionName\", \"type\": \"select\", \"label\": \"Choisissez une option :\", \"options\": [{\"name\": \"Décimal en Binaire\", \"value\": \"decimalToBinary\"}, {\"name\": \"Binaire en Décimal\", \"value\": \"binaryToDecimal\"}, {\"name\": \"Décimal en Hexadecimal\", \"value\": \"decimalToHexadecimal\"}, {\"name\": \"Hexadecimal en Décimal\", \"value\": \"hexadecimalToDecimal\"}, {\"name\": \"Binaire en Hexadécimal\", \"value\": \"binaryToHexadecimal\"}, {\"name\": \"Hexadécimal en Binaire\", \"value\": \"hexadecimalToBinary\"}, {\"name\": \"Chaque caractère a un nombre Unicode\", \"value\": \"textToNumberUnicode\"}, {\"name\": \"Chaque nombre Unicode a un caractère\", \"value\": \"numberUnicodeToText\"}, {\"name\": \"Texte en Binaire (UTF-8)\", \"value\": \"textToBinary\"}, {\"name\": \"Binaire (UTF-8) en Texte\", \"value\": \"binaryToText\"}, {\"name\": \"Texte en Hexadécimal (UTF-8)\", \"value\": \"textToHexadecimal\"}, {\"name\": \"Hexadécimal (UTF-8) en Texte\", \"value\": \"hexadecimalToText\"}], \"placeholder\": \"\"}]', 1, '2019-09-14 00:00:00', '2020-05-10 12:03:03', 2);
INSERT INTO `functions` (`id`, `title`, `slug`, `description`, `image`, `type`, `article`, `utilizationForm`, `isOnline`, `createdAt`, `updatedAt`, `categorieId`) VALUES
(9, 'Conversion d\'un nombre arabe en nombre romain', 'convertRomanArabicNumbers', 'Convertis un nombre arabe en nombre romain (et l\'inverse aussi).', '/images/functions/convertRomanArabicNumbers.png', 'form', '<p>Nous allons créer 2 fonctions, une qui convertis un nombre arabe en nombre romain et l\"autre qui fera dans l\"inverse.</p><p>Pour cela nous avons besoin d\"une variables de référence, qu\"on utilisera dans les deux fonctions :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">correspondancesRomainArabe</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;[</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">1000</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"M\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">900</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"CM\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">500</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"D\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">400</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"CD\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">100</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"C\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">90</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"XC\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">50</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"L\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">40</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"XL\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">10</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"X\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">9</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"IX\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">5</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"V\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">4</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"IV\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;[</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"I\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">];</span></div></div><p>- Commençons par la fonction qui convertis un nombre arabe en nombre romain :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Convertis&nbsp;un&nbsp;nombre&nbsp;arabe&nbsp;en&nbsp;nombre&nbsp;romain.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{number}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">nombre</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;arabe&nbsp;à&nbsp;convertir</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{string}</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@examples</span><span style=\"color: #6a9955;\">&nbsp;convertArabicToRoman(24)&nbsp;→&nbsp;\"XXIV\"</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">convertArabicToRoman</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">nombre</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #6a9955;\">//&nbsp;Initialisation&nbsp;de&nbsp;la&nbsp;variable&nbsp;qui&nbsp;va&nbsp;contenir&nbsp;le&nbsp;résultat&nbsp;de&nbsp;la&nbsp;conversion</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">chiffresRomains</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #ce9178;\">\"\"</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">extraireChiffreRomain</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">valeurLettre</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">lettre</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">while</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">nombre</span><span style=\"color: #d4d4d4;\">&nbsp;&gt;=&nbsp;</span><span style=\"color: #9cdcfe;\">valeurLettre</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">chiffresRomains</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">chiffresRomains</span><span style=\"color: #d4d4d4;\">&nbsp;+&nbsp;</span><span style=\"color: #9cdcfe;\">lettre</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">nombre</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">nombre</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #9cdcfe;\">valeurLettre</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">correspondancesRomainArabe</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">forEach</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">correspondance</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #569cd6;\">=&gt;</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #dcdcaa;\">extraireChiffreRomain</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">correspondance</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">],&nbsp;</span><span style=\"color: #9cdcfe;\">correspondance</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">]);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;});</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">chiffresRomains</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}&nbsp;</span></div></div><p>Au début on initialise le chiffresRomains à une chaîne de caractère vide, puis on créer la fonction extraireChiffreRomain qui prend en argument le nombre qui correspond à la lettre par exemple si la lettre c\"est \"V\" alors valeurLettre vaudra 5 puis la lettre romaine en question. Et tant qu\"on peut enlever la valeur de la lettre au nombre on continue la boucle while par exemple si on exécute la fonction&nbsp;extraireChiffreRomain(1000, \"M\"); avec nombre = 3000 alors la boucle se fera 3 fois, 1er tour de boucle nombre vaudra 2000 puis 1000 puis 0.</p><p>Et donc on fait une boucle forEach sur le tableau de référence et on exécute la fonction que j\"ai exécutée plus haut.</p><p>-&nbsp;Convertis un nombre romain en nombre arabe :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Convertis&nbsp;un&nbsp;nombre&nbsp;romain&nbsp;en&nbsp;nombre&nbsp;arabe.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{string}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;romain&nbsp;à&nbsp;convertir</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{number}</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@examples</span><span style=\"color: #6a9955;\">&nbsp;convertRomanToArabic(\'XXIV\')&nbsp;→&nbsp;24</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">convertRomanToArabic</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">correspondancesRomainArabe</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">forEach</span><span style=\"color: #d4d4d4;\">((</span><span style=\"color: #9cdcfe;\">correspondance</span><span style=\"color: #d4d4d4;\">)&nbsp;</span><span style=\"color: #569cd6;\">=&gt;</span><span style=\"color: #d4d4d4;\">&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">while</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">indexOf</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">correspondance</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">])&nbsp;===&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #6a9955;\">//&nbsp;Ajout&nbsp;de&nbsp;la&nbsp;valeur&nbsp;décimale&nbsp;au&nbsp;résultat</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">&nbsp;+=&nbsp;</span><span style=\"color: #9cdcfe;\">correspondance</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #6a9955;\">//&nbsp;Supprimer&nbsp;la&nbsp;lettre&nbsp;romaine&nbsp;correspondante&nbsp;du&nbsp;début</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">replace</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">correspondance</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">],&nbsp;</span><span style=\"color: #ce9178;\">\'\'</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;});</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">if</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">&nbsp;!=&nbsp;</span><span style=\"color: #ce9178;\">\'\'</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}&nbsp;</span></div></div><p>Au début le résultat = 0, puis on fait une boucle forEach sur le tableau de référence et on vérifie si la lettre en cours de l\'itération est dans la chaîne de caractère au 1er index (0) passée en argument, puis on rajoute la valeur de lettre au résultat exemple X c\'est 10 et on enlève la lettre de la chaîne de caractère. A la fin la chaîne de caractère doit être vide si ce n\'est pas le cas, c\'est que ce n\'est pas un chffre romain valide donc on retourne 0.</p>', '[{\"name\": \"value\", \"type\": \"text\", \"label\": \"Entrez votre nombre :\", \"placeholder\": \"(e.g : 50 ou L)\"}, {\"name\": \"functionName\", \"type\": \"select\", \"label\": \"Convertir en :\", \"options\": [{\"name\": \"Nombre Romain\", \"value\": \"convertArabicToRomanOutput\"}, {\"name\": \"Nombre Arabe\", \"value\": \"convertRomanToArabicOutput\"}], \"placeholder\": \"\"}]', 1, '2019-09-21 00:00:00', '2020-05-11 14:52:19', 2),
(10, 'Nombre d\'Armstrong', 'armstrongNumber', 'Permet de savoir si un nombre fait partie des nombres d\'Armstrong.', '/images/functions/armstrongNumber.png', 'form', '<p>Un nombre d\"Armstrong est un nombre entier positif qui est égal à la somme de ses chiffres portés à la puissance du nombre de chiffres le composant. Cette fonction permet de savoir si un nombre fait partie des nombres d\"Armstrong (avec l\"explication).<br>\n<br>\n\n\n\nExemple : 153 est un nombre d\"Armstrong&nbsp;car 1<sup>3</sup>&nbsp;+ 5<sup>3</sup>&nbsp;+ 3<sup>3</sup>&nbsp;= 153.</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Vérifie&nbsp;si&nbsp;un&nbsp;nombre&nbsp;fait&nbsp;partie&nbsp;des&nbsp;nombres&nbsp;d\'Armstrong.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{number}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">number</span><span style=\"color: #6a9955;\">&nbsp;-&nbsp;Le&nbsp;nombre&nbsp;à&nbsp;tester</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@return</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{boolean}</span><span style=\"color: #6a9955;\">&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@example</span><span style=\"color: #6a9955;\">&nbsp;isArmstrongNumber(153)&nbsp;→&nbsp;true</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span><span style=\"color: #d4d4d4;\">&nbsp;</span></div><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">isArmstrongNumber</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">number</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">numberString</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">number</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">toString</span><span style=\"color: #d4d4d4;\">();</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">;</span></div><br><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">for</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">;&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">&nbsp;&lt;&nbsp;</span><span style=\"color: #9cdcfe;\">numberString</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">;&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">++)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">&nbsp;+=&nbsp;</span><span style=\"color: #dcdcaa;\">parseInt</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">numberString</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">])&nbsp;**&nbsp;</span><span style=\"color: #9cdcfe;\">numberString</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><br><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">&nbsp;===&nbsp;</span><span style=\"color: #9cdcfe;\">number</span><span style=\"color: #d4d4d4;\">;&nbsp;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Pour cela, nous devons parcourir chaque chiffre du nombre individuellement, alors il faut transformer le nombre en string grâce à \".toString()\" et ensuite on peut initialiser la variable de résultat et faire les tours de boucle en incrémentant la variable de résultat et à la fin on regarde si le résultat est égale au nombre de base, si c\"est le cas c\"est que c\"est un nombre d\"Armstrong.</p>', '[{\"name\": \"number\", \"type\": \"integer\", \"label\": \"Entrez votre nombre :\", \"placeholder\": \"(e.g : 153)\"}]', 1, '2019-09-21 00:00:00', '2020-05-12 10:53:23', 2),
(11, 'Heap\'s algorithm', 'heapAlgorithm', 'Génère toutes les permutations uniques possibles d\'une chaîne de caractère.', '/images/functions/heapAlgorithm.png', 'form', NULL, '[{\"name\": \"string\", \"type\": \"text\", \"label\": \"Entrez un mot :\", \"placeholder\": \"(e.g : Mot)\"}]', 1, '2019-10-11 00:01:00', '2020-04-22 23:06:15', 2),
(12, 'Raccourcisseurs de liens', 'linkShortener', 'Une URL trop longue ? Raccourcissez-là !', '/images/functions/linkShortener.png', 'page', '<p>Pour faire son propre \"link shortener\" comme Bitly etc. Il faut une simple base de donnée (J\'utilise MySQL), avec 3 champs : id, url et shortcut. Le principe c\'est que vous avez une url prédéfinie (grâce à Express et NodeJS c\'est très simple), qui peut ressembler à ça : nomdedomaine.fr/?q=shortcut et à la place de \"shortcut\" c\'est le shortcut enregistré dans la base de donnée pour accéder à l\'url raccourci, donc l\'algo va se contenter de chercher dans sa base de donnée si le shortcut existe si oui il va prendre le champ url et faire un simple redirect. Pour que l\'algo fonctionne correctement, il faudrait que le shortcut soit unique.</p>', '[{\"name\": \"url\", \"type\": \"text\", \"label\": \"Entrez le lien à raccourcir :\", \"placeholder\": \"(e.g : https://divlo.fr)\"}, {\"name\": \"shortcutName\", \"type\": \"text\", \"label\": \"Entrez le nom du raccourci :\", \"placeholder\": \"(e.g : divlo)\"}]', 1, '2019-12-11 00:00:00', '2020-05-12 07:49:46', 1),
(13, 'Liste de choses à faire', 'toDoList', 'Prévoyez la liste de choses que vous devez faire.', '/images/functions/toDoList.png', 'page', '<p>La To do list c\'est l\'applications que tout les débutants font en programmation, c\'est le meilleur moyen de mettre en pratique les connaissances pour faire des applications CRUD (Create. Read. Update. Delete). Surtout qu\'avec un peu d\'imagination c\'est une app qui peut-être très grandement amélioré. Pour sauvegarder vos données vous pouvez utilisez le localStorage du navigateur ou encore mieux (ce que j\'utilise ici), un système de connexion/inscription des utilisateurs et sauvegarde des données en base de donnée (MySQL par exemple). Ici, l\'utilisateur peut ajouter une tâche à faire, voir les tâches ajoutées précédemment, déclarer comme fait et supprimer. Libre à vous d\'ajouter des fonctionnalités comme par exemple la possibilté de modifier une tâche ou encore de séparer les tâches faîtes des tâches en cours. Si vous apprennez le développement web, c\'est la 1ère application \"fullstack\" que vous pouvez faire simplement : HTML, CSS, JS et un langage côté serveur (PHP ou NodeJS par exemple).</p>', NULL, 1, '2019-12-26 00:00:00', '2020-05-12 10:49:48', 1),
(14, 'Juste Prix', 'rightPrice', 'Arriverez-vous à deviner le prix d\'un objet ?', '/images/functions/rightPrice.png', 'page', '<p>Faire un juste prix ce n\"est pas très compliqué, ça se résume en 3 conditions if, pour vérifier si le prix est inférieur/supérieur ou égale, donc très simple mais pour rendre le jeu un peu plus fun surtout à développer. J\"ai imaginé de prendre un produit d\"Amazon au hasard, d\"afficher le titre et l\"image et de faire deviner le prix du produit. Problème : Amazon ne possède pas d\"API (avec documentation etc.), donc pas moyen de récupérer les 3 informations que je veux d\"un produit.&nbsp;</p><p>Donc pas le choix, on va faire ce qu\"on appelle du \"Web scraping\", c\"est à dire qu\"on va faire un script qui va aller sur la page Amazon et on va prendre tout le HTML de la page, le stocké dans une variable et faire un DOM virtuel pour pouvoir accéder aux mêmes fonctions/méthodes en JavaScript comme le document.getElementById, document.querySelector etc. et donc pouvoir récupérer les valeurs voulues.</p><p>Pour cela j\"utilise NodeJS avec la librairie <a target=\"blank\" rel=\"noopener noreferrer\" href=\"https://github.com/segmentio/nightmare\">Nightmare</a>&nbsp;qui permet justement de faire du Web Scraping.<br>\n\nDonc l\"idée c\"est que nous allons faire une fonction qui va nous retourner un Tableau de produits d\"Amazon avec chaque produit c\"est un objet contenant comme information : le nom, l\"image et le prix.\n</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">async</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">getAmazonProductList</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">subject</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">url</span><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;</span><span style=\"color: #ce9178;\">`https://www.amazon.fr/s?k=</span><span style=\"color: #569cd6;\">${</span><span style=\"color: #9cdcfe;\">subject</span><span style=\"color: #569cd6;\">}</span><span style=\"color: #ce9178;\">`</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">Nightmare</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #dcdcaa;\">require</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\"nightmare\"</span><span style=\"color: #d4d4d4;\">)();</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #c586c0;\">await</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">Nightmare</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">goto</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">url</span><span style=\"color: #d4d4d4;\">)</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style=\"color: #dcdcaa;\">wait</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\".s-result-item\"</span><span style=\"color: #d4d4d4;\">)</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style=\"color: #dcdcaa;\">evaluate</span><span style=\"color: #d4d4d4;\">(()&nbsp;</span><span style=\"color: #569cd6;\">=&gt;</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">amazonProductList</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">document</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">querySelectorAll</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\".s-result-item\"</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">productsList</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;[];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">for</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">indexProduct</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #569cd6;\">in</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">amazonProductList</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">try</span><span style=\"color: #d4d4d4;\">&nbsp;{&nbsp;&nbsp;&nbsp;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">elementProduct</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">amazonProductList</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #9cdcfe;\">indexProduct</span><span style=\"color: #d4d4d4;\">];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">productImage</span><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">elementProduct</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">querySelector</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\".s-image\"</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">originalPrice</span><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">elementProduct</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">querySelector</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\".a-price-whole\"</span><span style=\"color: #d4d4d4;\">).</span><span style=\"color: #9cdcfe;\">innerHTML</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">productsList</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">push</span><span style=\"color: #d4d4d4;\">({</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">name:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">productImage</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #ce9178;\">\"alt\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">image:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">productImage</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #ce9178;\">\"src\"</span><span style=\"color: #d4d4d4;\">],</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">price:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #4ec9b0;\">Number</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">originalPrice</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">replace</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\",\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\".\"</span><span style=\"color: #d4d4d4;\">).</span><span style=\"color: #dcdcaa;\">replace</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\"&nbsp;\"</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #ce9178;\">\"\"</span><span style=\"color: #d4d4d4;\">))</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style=\"color: #c586c0;\">catch</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">_error</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">continue</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">productsList</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style=\"color: #dcdcaa;\">end</span><span style=\"color: #d4d4d4;\">();</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Je vous invite à voir la documentation de Nightmare mais là ce qu\"il faut comprendre c\"est qu\"on va à l\"url : `https://www.amazon.fr/s?k=${subject}`, où le subject c\"est la recherche sur amazon qui va s\"effectuer, donc par exemple si vous voulez faire deviner le prix d\"un smartphone vous&nbsp;appellerez cette fonction comme ça :&nbsp;getAmazonProductList(\"smartphone\"). On attend que tous les éléments qui ont la classe \".s-result-item\" ont fini de charger, puis on sélectionne tout éléments qui ont cette classe avec querySelectorAll on fait une boucle et on parcourt cette liste et on construit notre tableau qui contient les informations qu\"on veut.</p><p>Maintenant comme dans la fonction randomQuote, à la place de sélectionner une citation dans un tableau, on sélectionne un produit, exemple :\n</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">randomNumber</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">max</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #4ec9b0;\">Math</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">floor</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #4ec9b0;\">Math</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">random</span><span style=\"color: #d4d4d4;\">()&nbsp;*&nbsp;(</span><span style=\"color: #9cdcfe;\">max</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">&nbsp;+</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">))&nbsp;+&nbsp;</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div><br><div><span style=\"color: #dcdcaa;\">getAmazonProductList</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\'smartphone\'</span><span style=\"color: #d4d4d4;\">)</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style=\"color: #dcdcaa;\">then</span><span style=\"color: #d4d4d4;\">((</span><span style=\"color: #9cdcfe;\">productsList</span><span style=\"color: #d4d4d4;\">)&nbsp;</span><span style=\"color: #569cd6;\">=&gt;</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #4ec9b0;\">console</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">log</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">productsList</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #dcdcaa;\">randomNumber</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">productsList</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">)]);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;});</span></div></div><p>Puis ici je l\'affiche mais ensuite on peut en faire ce qu\'on veut de cette information est faire notre Juste Prix en manipulant le DOM etc.</p>', NULL, 1, '2020-04-27 20:17:05', '2020-05-12 12:46:28', 3),
(15, 'Chronomètre', 'chronometerTimer', 'Gérer votre temps facilement (et adopter la technique Pomodoro).', '/images/functions/chronometerTimer.png', 'page', '<p>Pour faire un chronomètre il faut utiliser la fonction globale setInterval, qui va exécuter une callback toutes les x nombres de millisecondes. Nous dans notre cas, chaque seconde on va incrémenter la variable de 1 pour connaître les secondes.</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">timeLength</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #dcdcaa;\">setInterval</span><span style=\"color: #d4d4d4;\">(()&nbsp;</span><span style=\"color: #569cd6;\">=&gt;</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">timeLength</span><span style=\"color: #d4d4d4;\">++;</span></div><div><span style=\"color: #d4d4d4;\">},&nbsp;</span><span style=\"color: #b5cea8;\">1000</span><span style=\"color: #d4d4d4;\">);</span></div></div><p>Puis pour afficher le nombre de minutes on va créer une fonction convertSeconds :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">convertSeconds</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">seconds</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">minutes:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #4ec9b0;\">Math</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">floor</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">seconds</span><span style=\"color: #d4d4d4;\">&nbsp;/&nbsp;</span><span style=\"color: #b5cea8;\">60</span><span style=\"color: #d4d4d4;\">),</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">seconds:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">seconds</span><span style=\"color: #d4d4d4;\">&nbsp;%&nbsp;</span><span style=\"color: #b5cea8;\">60</span><span style=\"color: #d4d4d4;\">&nbsp;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;};</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Exemple : On exécute la fonction convertSeconds(90) qui va nous retourner l\'objet où minutes vaudra 1 et seconds vaudra 30,&nbsp;</p><p>Et globalement le reste c\'est de la manipulation du DOM en JavaScript.</p>', NULL, 1, '2020-04-29 09:28:08', '2020-05-12 13:11:48', 1);
INSERT INTO `functions` (`id`, `title`, `slug`, `description`, `image`, `type`, `article`, `utilizationForm`, `isOnline`, `createdAt`, `updatedAt`, `categorieId`) VALUES
(16, 'Les méthodes des tableaux', 'arrayMethods', 'Et si on refaisait les méthodes natives de l\'objet global \"Array\" ?', '/images/functions/arrayMethods.png', 'article', '<p><strong>JavaScript</strong> est un langage <strong>orienté objet</strong>, chaque type comme \"String\",&nbsp; \"Number\", ... sont en réalité des objets.&nbsp; <br>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nCe sont des \"<a target=\"_blank\" href=\"https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux\">Objets globaux</a>\", qui dispose de méthodes bien utiles. 😎&nbsp; Pourquoi je vous dit ça ?<br>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nCar aujourd\"hui nous allons reproduire les méthodes de l\"objet global \"<a target=\"_blank\" href=\"https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Array\">Array</a>\",&nbsp; c\"est un bon exercice pour progresser.<br>\n<br>\n\n\n\n\n\n\n\n\n\n\n\nNous allons réaliser une classe (syntaxe ES6+) qu\"on va appeler \"DivloArray\" par exemple et reproduire 6 méthodes (push, forEach, map, filter, reverse et join), bien évidemment libre à vous d\"en faire plus. 😊 Je vais expliquer le code une méthode après l\"autre donc bout de code par bout de code, si vous voulez avoir le code source complet, il est disponible sur ce <a target=\"_blank\" href=\"https://gist.github.com/Divlo/4ffc8ed007d293372ee449d2647fcad9\">GitHub Gist.</a><br>\n<br>\n\n\n\n\n\n\n\n\n\n\nDonc tout d\"abord, nous devons créer la classe avec un constructor et faire une nouvelle instance de cet objet dans une variable :<br>\n\n\n\n\n\n\n\n\n(Libre à vous de renommer les variables comme bon vous semble.)&nbsp;<br>\n</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">class</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #4ec9b0;\">DivloArray</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">constructor</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">}</span></div><br>\n\n<div><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">divloArray</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #569cd6;\">new</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #4ec9b0;\">DivloArray</span><span style=\"color: #d4d4d4;\">([</span><span style=\"color: #b5cea8;\">57</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #b5cea8;\">4</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #b5cea8;\">2</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #b5cea8;\">8</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #b5cea8;\">16</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #b5cea8;\">25</span><span style=\"color: #d4d4d4;\">]);</span></div></div><p><br>\n\n\n\n\n\n\n- Nous allons commencer par créer la première méthode très utilisée qui consiste à ajouter un ou plusieurs éléments à la fin d\"un tableau, je parle bien évidemment de la méthode <strong>push</strong>.</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Ajoute&nbsp;un&nbsp;ou&nbsp;plusieurs&nbsp;éléments&nbsp;à&nbsp;la&nbsp;fin&nbsp;d\"un&nbsp;tableau&nbsp;et&nbsp;retourne&nbsp;la&nbsp;nouvelle&nbsp;taille&nbsp;du&nbsp;tableau.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{*}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">elements</span><span style=\"color: #6a9955;\">&nbsp;Éléments&nbsp;à&nbsp;ajoutés</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{Number}</span><span style=\"color: #6a9955;\">&nbsp;La&nbsp;taille&nbsp;(length)&nbsp;du&nbsp;nouveau&nbsp;tableau</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #dcdcaa;\">push</span><span style=\"color: #d4d4d4;\">(...</span><span style=\"color: #9cdcfe;\">elements</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">indexCourant</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">elements</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">forEach</span><span style=\"color: #d4d4d4;\">((</span><span style=\"color: #9cdcfe;\">element</span><span style=\"color: #d4d4d4;\">)&nbsp;</span><span style=\"color: #569cd6;\">=&gt;</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #9cdcfe;\">indexCourant</span><span style=\"color: #d4d4d4;\">]&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">element</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">indexCourant</span><span style=\"color: #d4d4d4;\">++;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;});</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Alors on prend en paramètre des éléments avec le spread operator ce qui nous permet d\"obtenir un tableau (exemple: 1, 2, 3 devient [1, 2, 3]). On fait une variable indexCourant qui est égale à la taille du tableau qu\"on incrémentera de 1 à chaque tour de boucle, comme ça on peut accéder à l\"index qui n\"existe pas encore et lui attribuer une valeur, l\"élement en cours de la boucle, si vous avez des questions n\"hésitez pas à les poster en commentaire.<br>\n<br>\n\n\n\n\n\n\n- La méthode <strong>forEach :&nbsp;</strong></p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Permet&nbsp;d\"exécuter&nbsp;une&nbsp;fonction&nbsp;donnée&nbsp;sur&nbsp;chaque&nbsp;élément&nbsp;du&nbsp;tableau.&nbsp;</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{Function}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">callback</span><span style=\"color: #6a9955;\">&nbsp;Une&nbsp;fonction&nbsp;qui&nbsp;accepte&nbsp;jusqu\"à&nbsp;trois&nbsp;arguments&nbsp;:</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;-&nbsp;valeurCourante&nbsp;→&nbsp;La&nbsp;valeur&nbsp;de&nbsp;l\"élément&nbsp;du&nbsp;tableau&nbsp;en&nbsp;cours&nbsp;de&nbsp;traitement.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;-&nbsp;index&nbsp;→&nbsp;L\"indice&nbsp;de&nbsp;l\"élément&nbsp;du&nbsp;tableau&nbsp;en&nbsp;cours&nbsp;de&nbsp;traitement.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;-&nbsp;array&nbsp;→&nbsp;Le&nbsp;tableau&nbsp;sur&nbsp;lequel&nbsp;la&nbsp;méthode&nbsp;forEach&nbsp;est&nbsp;appliquée.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #dcdcaa;\">forEach</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">callback</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">for</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">;&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">&nbsp;&lt;&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">;&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">++)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">valeurCourante</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #dcdcaa;\">callback</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">valeurCourante</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Prend une fonction callback, c\"est à dire une fonction qui va être exécutée dans le corps de la fonction et on fait une simple boucle for.<br>\n<br>\n\n\n\n\n\n- La méthode <strong>map</strong>&nbsp;:</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Crée&nbsp;un&nbsp;nouveau&nbsp;tableau&nbsp;avec&nbsp;les&nbsp;résultats&nbsp;de&nbsp;l\"appel&nbsp;d\"une&nbsp;fonction&nbsp;fournie&nbsp;sur&nbsp;chaque&nbsp;élément&nbsp;du&nbsp;tableau&nbsp;appelant.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{Function}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">callback</span><span style=\"color: #6a9955;\">&nbsp;Une&nbsp;fonction&nbsp;qui&nbsp;accepte&nbsp;jusqu\"à&nbsp;trois&nbsp;arguments.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;-&nbsp;valeurCourante&nbsp;→&nbsp;La&nbsp;valeur&nbsp;de&nbsp;l\"élément&nbsp;du&nbsp;tableau&nbsp;en&nbsp;cours&nbsp;de&nbsp;traitement.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;-&nbsp;index&nbsp;→&nbsp;L\"indice&nbsp;de&nbsp;l\"élément&nbsp;du&nbsp;tableau&nbsp;en&nbsp;cours&nbsp;de&nbsp;traitement.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;-&nbsp;array&nbsp;→&nbsp;Le&nbsp;tableau&nbsp;sur&nbsp;lequel&nbsp;la&nbsp;méthode&nbsp;est&nbsp;appliquée.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{Array}</span><span style=\"color: #6a9955;\">&nbsp;Un&nbsp;nouveau&nbsp;tableau&nbsp;composé&nbsp;des&nbsp;images&nbsp;de&nbsp;la&nbsp;fonction&nbsp;de&nbsp;rappel.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #dcdcaa;\">map</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">callback</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;[...</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">];&nbsp;</span><span style=\"color: #6a9955;\">//&nbsp;permet&nbsp;de&nbsp;ne&nbsp;pas&nbsp;changer&nbsp;les&nbsp;valeurs&nbsp;du&nbsp;tableau&nbsp;original&nbsp;(car&nbsp;passage&nbsp;par&nbsp;référence)</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">forEach</span><span style=\"color: #d4d4d4;\">((</span><span style=\"color: #9cdcfe;\">elementCourant</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">indexCourant</span><span style=\"color: #d4d4d4;\">)&nbsp;</span><span style=\"color: #569cd6;\">=&gt;</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #9cdcfe;\">indexCourant</span><span style=\"color: #d4d4d4;\">]&nbsp;=&nbsp;</span><span style=\"color: #dcdcaa;\">callback</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">elementCourant</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">indexCourant</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;});</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p><br>\n\n\n\n\n- La méthode <strong>filter</strong> :&nbsp;</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Retourne&nbsp;un&nbsp;nouveau&nbsp;tableau&nbsp;contenant&nbsp;tous&nbsp;les&nbsp;éléments&nbsp;du&nbsp;tableau&nbsp;d\"origine&nbsp;qui&nbsp;remplissent&nbsp;une&nbsp;condition&nbsp;déterminée&nbsp;par&nbsp;la&nbsp;fonction&nbsp;callback.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{Function}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">callback</span><span style=\"color: #6a9955;\">&nbsp;La&nbsp;fonction&nbsp;de&nbsp;test&nbsp;à&nbsp;appliquer&nbsp;à&nbsp;chaque&nbsp;élément&nbsp;du&nbsp;tableau.&nbsp;Cette&nbsp;fonction&nbsp;est&nbsp;appelée&nbsp;avec&nbsp;les&nbsp;arguments&nbsp;suivants&nbsp;:</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;-&nbsp;elementCourant&nbsp;→&nbsp;L\"élément&nbsp;à&nbsp;traiter</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;-&nbsp;index&nbsp;→&nbsp;Son&nbsp;indice</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;-&nbsp;array&nbsp;→&nbsp;Le&nbsp;tableau&nbsp;complet</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{Array}</span><span style=\"color: #6a9955;\">&nbsp;Un&nbsp;nouveau&nbsp;tableau&nbsp;contenant&nbsp;les&nbsp;éléments&nbsp;qui&nbsp;respectent&nbsp;la&nbsp;condition&nbsp;du&nbsp;filtre.&nbsp;Si&nbsp;aucun&nbsp;élément&nbsp;ne&nbsp;respecte&nbsp;la&nbsp;condition,&nbsp;c\"est&nbsp;un&nbsp;tableau&nbsp;vide&nbsp;qui&nbsp;est&nbsp;renvoyé.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #dcdcaa;\">filter</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">callback</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">resultArray</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;[];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">forEach</span><span style=\"color: #d4d4d4;\">((</span><span style=\"color: #9cdcfe;\">elementCourant</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">indexCourant</span><span style=\"color: #d4d4d4;\">)&nbsp;</span><span style=\"color: #569cd6;\">=&gt;</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">isTrue</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #dcdcaa;\">callback</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">elementCourant</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">indexCourant</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">if</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">isTrue</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">resultArray</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">push</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">elementCourant</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;});</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">resultArray</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Comme on peut le voir beaucoup de ces méthodes recoivent une fonction callback, en tout cas, cette méthode ressemble beaucoup à la méthode map sauf que cette fois çi à la place de faire une assignation on vérifie si la callback nous renvoie True et si oui on push l\"élément à notre tableau de résultats.<br>\n<br>\n\n\n- La méthode <strong>reverse</strong> qui inverse le tableau :&nbsp;</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@description</span><span style=\"color: #6a9955;\">&nbsp;Transpose&nbsp;les&nbsp;éléments&nbsp;d\"un&nbsp;tableau&nbsp;:&nbsp;le&nbsp;premier&nbsp;élément&nbsp;devient&nbsp;le&nbsp;dernier&nbsp;et&nbsp;le&nbsp;dernier&nbsp;devient&nbsp;le&nbsp;premier&nbsp;et&nbsp;ainsi&nbsp;de&nbsp;suite.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{Array}</span><span style=\"color: #6a9955;\">&nbsp;Le&nbsp;tableau&nbsp;inversé</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #dcdcaa;\">reverse</span><span style=\"color: #d4d4d4;\">()&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">reverseArray</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;[];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">for</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">;&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">&nbsp;&gt;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">;&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">--)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">element</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">reverseArray</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">push</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">element</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">reverseArray</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>On fait l\"inverse de la méthode forEach, à la place de commencer l\"index à 0 et de l\"incrémenter par 1, cette fois çi on commence par le nombre d\"éléments dans le tableau - 1, et on enlève 1 à chaque tour de boucle.<br>\n<br>\n\n- Et pour finir la méthode <strong>join</strong> :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #6a9955;\">/**</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;Crée&nbsp;et&nbsp;renvoie&nbsp;une&nbsp;nouvelle&nbsp;chaîne&nbsp;de&nbsp;caractères&nbsp;en&nbsp;concaténant&nbsp;tous&nbsp;les&nbsp;éléments&nbsp;d\'un&nbsp;tableau</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@param</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{String}</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #9cdcfe;\">separator</span><span style=\"color: #6a9955;\">&nbsp;Ce&nbsp;paramètre&nbsp;optionnel&nbsp;indique&nbsp;une&nbsp;chaine&nbsp;de&nbsp;caractères&nbsp;pour&nbsp;séparer&nbsp;chaque&nbsp;élément&nbsp;du&nbsp;tableau</span></div><div><span style=\"color: #6a9955;\">&nbsp;*&nbsp;</span><span style=\"color: #569cd6;\">@returns</span><span style=\"color: #6a9955;\">&nbsp;</span><span style=\"color: #4ec9b0;\">{String}</span><span style=\"color: #6a9955;\">&nbsp;Une&nbsp;chaîne&nbsp;de&nbsp;caractères&nbsp;composée&nbsp;de&nbsp;tous&nbsp;les&nbsp;éléments&nbsp;du&nbsp;tableau&nbsp;joints&nbsp;les&nbsp;uns&nbsp;aux&nbsp;autres.</span></div><div><span style=\"color: #6a9955;\">&nbsp;*/</span></div><div><span style=\"color: #dcdcaa;\">join</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">separator</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #ce9178;\">\",\"</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">resultString</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #ce9178;\">\"\"</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">forEach</span><span style=\"color: #d4d4d4;\">((</span><span style=\"color: #9cdcfe;\">element</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">)&nbsp;</span><span style=\"color: #569cd6;\">=&gt;</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">if</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #569cd6;\">this</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">&nbsp;===&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">)&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">resultString</span><span style=\"color: #d4d4d4;\">&nbsp;+=&nbsp;</span><span style=\"color: #9cdcfe;\">element</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">resultString</span><span style=\"color: #d4d4d4;\">&nbsp;+=&nbsp;</span><span style=\"color: #9cdcfe;\">element</span><span style=\"color: #d4d4d4;\">&nbsp;+&nbsp;</span><span style=\"color: #9cdcfe;\">separator</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;});</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">resultString</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Juste petite subtilité, on ne doit pas rajouter le séparateur à la dernière itrération de la boucle et donc pour ça on fait une simple condition.<br>\n<br>\nAlors ? Ce n\"est pas très compliqué, mais je trouve c\"est important de comprendre comment les méthodes/fonctions fonctionnent avant de s\"en servir et savoir les refaire c\"est toujours un bon plus même si en réalité dans un projet on ne va juste utiliser ces méthodes sans réfléchir comment elles fonctionnent.</p>', NULL, 1, '2020-04-29 20:16:09', '2020-05-06 10:50:26', 4),
(17, 'Est-ce un palindrome ?', 'isPalindrome', 'Un palindrome est un mot (ou phrase) qui peut s\'écrire dans les deux sens (ex: kayak).', '/images/functions/isPalindrome.png', 'form', '<p>Pour réfléchir sur un problème, il faut le \"découper\" en petits autres problèmes, un palindrome est un mot qui peut s\"écrire dans les deux sens, donc le mot avec les lettres inversées devrait être exactement le même que le mot initial.<br>\n\n\nDonc pour cela faut d\"abord faire une fonction qui va retourner la chaîne de caractère à l\"envers, par exemple : \"Hello\" devient \"olleH.</p><p>Je vais vous montrer 2 techniques différentes pour arriver à écrire la fonction \"reverseString\" :</p><p>- 1ère méthode consiste à simplement faire une boucle à l\"envers :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">reverseString</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #ce9178;\">\"\"</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">stringLength</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">&nbsp;-&nbsp;</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">for</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">stringLength</span><span style=\"color: #d4d4d4;\">;&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">&nbsp;&gt;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">;&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">--)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">&nbsp;+=&nbsp;</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>- 2ème méthode qui tient sur une seule ligne grâce aux méthodes des objets globaux :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">reverseString</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">split</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\"\"</span><span style=\"color: #d4d4d4;\">).</span><span style=\"color: #dcdcaa;\">reverse</span><span style=\"color: #d4d4d4;\">().</span><span style=\"color: #dcdcaa;\">join</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\"\"</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Ici on \"split\" la chaîne de caractère sur chaque lettre (exemple: \"test\" devient&nbsp;[\"t\", \"e\", \"s\", \"t\"]), puis on utilise la méthode reverse() qui inverse le tableau et pour finir join qui nous permet d\"avoir une chaîne de caractères.</p><p>Maintenant, on peut rédiger la fonction \"isPalindrome\" :&nbsp;</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">isPalindrome</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">&nbsp;===&nbsp;</span><span style=\"color: #dcdcaa;\">reverseString</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Cette fonction nous renvoie simplement un booléen si oui ou non c\'est un palindrome.</p>', '[{\"name\": \"string\", \"type\": \"text\", \"label\": \"Entrez la chaîne de caractères à vérifier :\", \"placeholder\": \"(e.g : kayak)\"}]', 1, '2020-05-06 20:16:41', '2020-05-08 07:06:10', 2),
(18, 'Quel est le mot le plus long ?', 'findLongestWord', 'Trouve le mot le plus long dans une chaîne de caractères.', '/images/functions/findLongestWord.png', 'form', '<p></p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">findLongestWord</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">arrayString</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">string</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">split</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #ce9178;\">\"&nbsp;\"</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">wordLength</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">wordResult</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #ce9178;\">\"\"</span><span style=\"color: #d4d4d4;\">;</span></div><br><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">arrayString</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">forEach</span><span style=\"color: #d4d4d4;\">((</span><span style=\"color: #9cdcfe;\">word</span><span style=\"color: #d4d4d4;\">)&nbsp;</span><span style=\"color: #569cd6;\">=&gt;</span><span style=\"color: #d4d4d4;\">&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">if</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">word</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">&nbsp;&gt;&nbsp;</span><span style=\"color: #9cdcfe;\">wordLength</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">wordResult</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">word</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">wordLength</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">word</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;});</span></div><br><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">wordResult</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>On part du principe que chaque mot est séparé par des espaces. Au début, le mot le plus long a 0 caractère. Puis on fait une boucle qui vérifie si le mot qu\'on est en train de vérifier est plus long que le mot qui était jusqu\'à cette itération le plus long, si c\'est le cas, on met à jour les variables du mot le plus long, pour vérifier si c\'est encore le cas à la prochaine itération.</p>', '[{\"name\": \"string\", \"type\": \"text\", \"label\": \"Entrez la chaîne de caractères (phrase) à vérifier :\", \"placeholder\": \"(e.g : Une phrase quelconque.)\"}]', 1, '2020-05-06 20:29:05', '2020-05-08 07:23:23', 2),
(19, 'Suite de Fibonacci', 'fibonacci', 'Calcule la suite de Fibonacci.', '/images/functions/fibonacci.png', 'form', '<p>La suite de Fibonacci est une suite d\"entiers dans laquelle chaque terme est la somme des deux termes qui le précèdent, voici les 6 premiers chiffres de la suite :<br>\n\n\n\n\n\n0, 1, 1, 2, 3, 5</p><p>Nous allons coder une fonction récursive qui va nous calculer les \"x\" premiers nombres de la suite.</p><p>Pour commencer qu\"est ce qu\"une fonction récursive ? Une fonction récursive est une fonction qui s\"auto appelle dans le corps de la fonction, exemple :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">doSomeCode</span><span style=\"color: #d4d4d4;\">()&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #dcdcaa;\">doSomeCode</span><span style=\"color: #d4d4d4;\">();</span></div><div><span style=\"color: #d4d4d4;\">}</span></div><div><span style=\"color: #dcdcaa;\">doSomeCode</span><span style=\"color: #d4d4d4;\">();</span></div></div><p>Bon ici, ça n\"a pas trop de sens, car ça causerait \"une boucle infinie\" on obtiendra une \"InternalError: too much recursion\", par contre si on exécute la fonction ou on retourne une valeur d\"après des conditions, ça peut-être très intéressant.</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">fibonacci</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">counter</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;[],&nbsp;</span><span style=\"color: #9cdcfe;\">number1</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">number2</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">if</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">counter</span><span style=\"color: #d4d4d4;\">&nbsp;===&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">;&nbsp;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">counter</span><span style=\"color: #d4d4d4;\">--;</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">push</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">number1</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">fibonacci</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">counter</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">result</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">number2</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">number1</span><span style=\"color: #d4d4d4;\">&nbsp;+&nbsp;</span><span style=\"color: #9cdcfe;\">number2</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Cette fonction a en réalité un seul argument qui doit être passé lors de la première exécution, le \"counter\", le reste c\'est des arguments qu\"on passera dans le corps de la fonction quand on la réecutera.</p><p>On décrémente counter de -1 à chaque itération donc si counter est égale à 0 c\"est qu\"il faut retourner la suite de nombres sinon on peut continuer à push des nombres dans la liste.<br>\nPour rajouter des nombres dans la liste, il nous faut 2 variables (les deux termes qui précèdent) qui ici nous appelons \"number1\" et \"number2\".</p>', '[{\"name\": \"counter\", \"type\": \"integer\", \"label\": \"Combien de nombres de la suite de fibonacci voulez vous calculer ?\", \"placeholder\": \"(e.g : 14)\"}]', 1, '2020-05-06 20:43:21', '2020-05-08 12:02:53', 2);
INSERT INTO `functions` (`id`, `title`, `slug`, `description`, `image`, `type`, `article`, `utilizationForm`, `isOnline`, `createdAt`, `updatedAt`, `categorieId`) VALUES
(20, 'Trie les éléments d\'un tableau', 'sortArray', 'Trie les éléments d\'un tableau dans l\'ordre croissant.', '/images/functions/sortArray.png', 'form', '<p>Le but ici c\"est de recevoir un tableau de nombres et de pouvoir remettre dans l\"ordre croissant le tableau (exemple : [4, 12, 1, 8] devient [1, 4, 8, 12]).</p><p>Comme je le dis souvent, il faut penser un problème en petits autres problèmes plus facilement atteignable. Pour commencer, je décide de faire une fonction qui me retourne le nombre le plus petit d\"un tableau.<br>\n</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">minNumber</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">minNumber</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;{&nbsp;</span><span style=\"color: #9cdcfe;\">index:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">value:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #b5cea8;\">0</span><span style=\"color: #d4d4d4;\">]&nbsp;};</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">for</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #569cd6;\">let</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">;&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">&nbsp;&lt;&nbsp;</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">;&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">++)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">number</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">if</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">number</span><span style=\"color: #d4d4d4;\">&nbsp;&lt;&nbsp;</span><span style=\"color: #9cdcfe;\">minNumber</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">minNumber</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;{&nbsp;</span><span style=\"color: #9cdcfe;\">index:</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #9cdcfe;\">value:</span><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">[</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">]&nbsp;};</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">minNumber</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Cette fonction retourne un objet contenant la valeur ainsi que son index du nombre le plus petit du tableau passé en argument.</p><p>Ensuite on peut passer à la fonction sortArray :</p><div class=\"vscode-editor\" style=\"color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, \'Courier New\', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;\"><div><span style=\"color: #569cd6;\">function</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #dcdcaa;\">sortArray</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">arrayDuplicated</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;[...</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">resultArray</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;[];</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">while</span><span style=\"color: #d4d4d4;\">&nbsp;(</span><span style=\"color: #9cdcfe;\">array</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">&nbsp;!==&nbsp;</span><span style=\"color: #9cdcfe;\">resultArray</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">length</span><span style=\"color: #d4d4d4;\">)&nbsp;{</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #569cd6;\">const</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #51b6c4;\">min</span><span style=\"color: #d4d4d4;\">&nbsp;=&nbsp;</span><span style=\"color: #dcdcaa;\">minNumber</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">arrayDuplicated</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">resultArray</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">push</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">value</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #9cdcfe;\">arrayDuplicated</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #dcdcaa;\">splice</span><span style=\"color: #d4d4d4;\">(</span><span style=\"color: #9cdcfe;\">min</span><span style=\"color: #d4d4d4;\">.</span><span style=\"color: #9cdcfe;\">index</span><span style=\"color: #d4d4d4;\">,&nbsp;</span><span style=\"color: #b5cea8;\">1</span><span style=\"color: #d4d4d4;\">);</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div><span style=\"color: #d4d4d4;\">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=\"color: #c586c0;\">return</span><span style=\"color: #d4d4d4;\">&nbsp;</span><span style=\"color: #9cdcfe;\">resultArray</span><span style=\"color: #d4d4d4;\">;</span></div><div><span style=\"color: #d4d4d4;\">}</span></div></div><p>Je duplique mon tableau (\"arrayDuplicated\") grâce au spread operator, c\'est sur ce tableau que je vais supprimer le nombre minimum pour l\'ajouter au tableau de resultat (\"resultArray\"), je fais une boucle while tant que le tableau de résultats n\'est pas égale au tableau initiale c\'est qu\'il faut rajouter encore des valeurs et continuer la boucle, splice modifie le tableau et \"array.splice(index, 1)\" permet de supprimer l\'élément à l\'index voulu, ici l\'index du nombre qu\'on a ajouté au tableau de résultat.</p>', '[{\"name\": \"numbersList\", \"type\": \"text\", \"label\": \"Entrez une liste de nombres (séparées par des virgules) :\", \"placeholder\": \"(e.g : 4, 12, 1, 8)\"}]', 1, '2020-05-06 20:57:48', '2020-05-08 13:17:26', 2);
