From 37c5ab6193cdc8c3d124fb7ef659cd545957f9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex?= Date: Thu, 12 Oct 2023 12:49:32 +0200 Subject: [PATCH 1/2] Reto #40 - javascript --- .../javascript/alexgarcia.js" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia.js" diff --git "a/Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia.js" "b/Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia.js" new file mode 100644 index 0000000000..c631d0d47a --- /dev/null +++ "b/Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia.js" @@ -0,0 +1,22 @@ +const prompt = require("prompt-sync")(); + +// Ask and validate whether is a number +function askAndValidateNumber() { + let number = parseInt(prompt("Ingrese un valor para imprimir su tabla de multiplicar del 1 hasta el 10: ")); + + if (typeof number === 'number' && !isNaN(number)) { + generateMultiplicationTable(number); + } else { + console.log("Debes ingresar un numero.") + } +} + +// Generate multiplication table for entered number +function generateMultiplicationTable(number) { + for (let i = 1; i <= 10; i++) { + let multiplicationResult = number * i + console.log(`${number} x ${i} = ${multiplicationResult}`) + } +} + +askAndValidateNumber() \ No newline at end of file From a81195dcd836da5d868a4b41ac82d91fada0e64f Mon Sep 17 00:00:00 2001 From: alexgarcia1907 <72034975+alexgarcia1907@users.noreply.github.com> Date: Mon, 16 Oct 2023 12:40:18 +0200 Subject: [PATCH 2/2] Rename alexgarcia.js to alexgarcia1907.js --- .../javascript/alexgarcia1907.js" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia.js" => "Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia1907.js" (96%) diff --git "a/Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia.js" "b/Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia1907.js" similarity index 96% rename from "Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia.js" rename to "Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia1907.js" index c631d0d47a..ffd00fa33a 100644 --- "a/Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia.js" +++ "b/Retos/Reto #40 - TABLA DE MULTIPLICAR [F\303\241cil]/javascript/alexgarcia1907.js" @@ -19,4 +19,4 @@ function generateMultiplicationTable(number) { } } -askAndValidateNumber() \ No newline at end of file +askAndValidateNumber()