This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
FunctionProject/.github/backup.sql

32 lines
144 KiB
MySQL
Raw Normal View History

/* 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),
2020-05-13 00:25:23 +02:00
(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</sp
(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;==
(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><sp
(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=\"
(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),
2020-05-13 00:25:23 +02:00
(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<
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><s
(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:
(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),
2020-08-03 20:56:01 +02:00
(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),
2020-05-13 00:25:23 +02:00
(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: #569c
(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 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:
(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><s
(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 un
(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
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