funciones
This commit is contained in:
49
funciones.js
Normal file
49
funciones.js
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
function saludo(nombre) {
|
||||||
|
console.log("Sintaxis basica de funcion reutilizable", "Hola soy " + nombre);
|
||||||
|
}
|
||||||
|
|
||||||
|
saludo("Luciano");
|
||||||
|
saludo("Facundo");
|
||||||
|
|
||||||
|
function sumaDeValores(num1, num2) {
|
||||||
|
return num1 + num2
|
||||||
|
}
|
||||||
|
console.log("return devuelve valor especifico ")
|
||||||
|
console.log(sumaDeValores(500, 500));
|
||||||
|
|
||||||
|
let calcular = function (num1, num2) {
|
||||||
|
return num1 * num2
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("funcion anonima desde variable")
|
||||||
|
console.log(calcular(5, 5));
|
||||||
|
|
||||||
|
function presentadorClima(nombre = "Luciano") {
|
||||||
|
console.log("Hola soy, " + nombre)
|
||||||
|
}
|
||||||
|
|
||||||
|
presentadorClima("parametros predeterminados")
|
||||||
|
presentadorClima()
|
||||||
|
|
||||||
|
|
||||||
|
const funcionFlecha = (nombre) => console.log("Mi nombre es " + nombre);
|
||||||
|
|
||||||
|
console.log("sintaxis de una linea de codigo, funcion flecha")
|
||||||
|
|
||||||
|
funcionFlecha("luciano")
|
||||||
|
|
||||||
|
const calcularDistancia = (tiempo, kilometros) => {
|
||||||
|
const distanciaExacta = tiempo * kilometros;
|
||||||
|
return distanciaExacta
|
||||||
|
}
|
||||||
|
console.log("uso de return en funcion flecha")
|
||||||
|
console.log(calcularDistancia(5, 4));
|
||||||
|
|
||||||
|
const CalcularDisProlijo = (tiempo, kilometros) => {
|
||||||
|
return tiempo * kilometros
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("uso de return mas prolijo")
|
||||||
|
console.log(CalcularDisProlijo(5, 5));
|
||||||
|
|
||||||
|
|
||||||
7
oso.js
7
oso.js
@@ -24,11 +24,7 @@ switch (true) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (temperaturaRandom <= 10) estacion = 'Invierno';
|
|
||||||
else if (temperaturaRandom > 10 && temperaturaRandom <= 15) estacion = 'Otoño';
|
|
||||||
else if (temperaturaRandom > 15 && temperaturaRandom <= 24) estacion = 'Primavera';
|
|
||||||
else estacion = 'Verano';
|
|
||||||
*/
|
|
||||||
const mensaje = `
|
const mensaje = `
|
||||||
${saludo}
|
${saludo}
|
||||||
Hoy ${hoy} de ${estacion}, tenemos una temperatura de ${temperaturaRandom}°.
|
Hoy ${hoy} de ${estacion}, tenemos una temperatura de ${temperaturaRandom}°.
|
||||||
@@ -36,3 +32,4 @@ ${consejos[estacion]}
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
console.log(mensaje);
|
console.log(mensaje);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user