Está en la página 1de 14

HOLA MUNDO (MODULO 1)

let saludo = "¡Hola mundo!";

console.log(saludo);

let edad = 30
let peso = 50

DECLARACION DE VARIABLES (MODULO 3)


let numeroA=10;
let numeroB=20;
let resultadoSuma = numeroA + numeroB
let resultadoResta = numeroA - numeroB
let resultadoMultiplicacion = numeroA * numeroB
let resultadoDivision = numeroA / numeroB

MAS OPERACIONES (MODULO 3)

let nombre = "Josefina";


let apellido = "Perez";

let nombreCompleto = nombre + " " + apellido;

OTROS TIPOS DE DATOS (MODULO 3)

let saludo = "¡Hola mundo!";

MAS TIPOS DE DATOS (MODULO 3)


let meGustaElHelado = true;
MAS SOBRE BOOLEANOS (MODULO 3)

let unNumeroChico = 4;
let unNumeroGrande = 10;
let esMenor = 4 < 10;
let esMayor = unNumeroChico > unNumeroGrande;

ARRAYS (MODULO 4)

let seriesFavoritasDeAna = ["Game of Thrones", "Breaking


Bad", "House of Cards"];
let seriesFavoritasDeHector = ["En Terapia", "Recordando
el Show de Alejandro Molina"]
let a = ["hola","mundo!"]
let b = ["hola","hola!"]

console.log (seriesFavoritasDeAna)
console.log (seriesFavoritasDeHector)
console.log (a)
console.log (b)

CICLOS (MODULO 4)

function imprimirAzul4(){
for (let i = 1; i<=4; i++){
console.log ("Azul")
}
}
JUEGOS DE AZAR ( MODULO 5)

let numerosDeLoteria = [2, 11, 17, 32, 36, 39];


let tiradasDelDado = [1, 6, 6, 2, 2, 4];
let salioCara = [false, false, true, false];
let listaDeListasDeNumeros = [[1, 6], [6, 2, 2, 4]];
console.log (numerosDeLoteria)
console.log (tiradasDelDado)
console.log (salioCara)
console.log (listaDeListasDeNumeros)

ARRAYS VACIOS (MODULO 5)

let otroArrayVacio = [];

CUANTOS ELEMENTOS TENES? (MODULO 5)

let numerosDeLoteria = [22,40,12]


console.log ([].length);
console.log (numerosDeLoteria.length);
console.log ([4, 3].length);

AGRAGANDO SABRO (MODULO 5)

let pertenencias = [ "espada" , "escudo" , "antorcha" ];


console.log (pertenencias);
pertenencias.push ("ballesta");
console.log (pertenencias);
TRASLADAR (MODULO 5)

function trasladar (a,b){


let c= a.pop()
let d= b.push (c)
}

Y DONDE ESTA? (MODULO 5)

let miArray = ["A", "la", "grande", "le", "puse",


"cuca"];
let posicion = miArray.indexOf("grande");

let diasLaborales = ["Lunes", "Martes", "Miércoles",


"Jueves", "Viernes"];
let unDia = diasLaborales.indexOf("Lunes");{

}
console.log (diasLaborales.indexOf("Osvaldo"));

CONTIENE (MODULO 5)

function contiene (array, numero){


if (array.indexOf (numero) != -1){
return true;}
else
{return false;}
}

ENESIMO ELEMENTO (MODULO 5)

let valores = ["a","b","c","d"];


console.log (valores[valores.length-1]);
MAS PREMIOS (MODULO 5)

function medallaSegunPuesto (puesto){


let medalla = ["Oro", "Plata", "Bronce", "Seguí
participando"]
if (puesto >=4){
return "Seguí participando";}
else {
return medalla [puesto -1];
}

CICLOS:
REFORZANDO CONCEPTOS (MODULO 5)

function imprimir5veces5(){
for (let i = 0; i < 5; i++){
console. log (5)
}
}

PASITO A PASITO

function pasitoAPasito () {
for (let i = 0; i<5; i++){
console.log(i)
}
}
HAGAMOS UNA MAS!

function pasandoPorI() {
for (let i = 0; i < 5; i++){
console.log ("acá i tiene el valor de " + i);
}
}

PAR O NO PAR

function pasandoPorLosPares() {
for (let i = 0; i <= 6 && i % 2 == 0; i += 2){
console.log ("acá i tiene el valor de " + i)
}
}

REPETICION VARIABLE

function imprimirAzul (ab) {


for (let i = 0; i < ab; i++){
console.log ("Azul");
}
}

ACUMULADORES

function sumar5MonedasDe25Centavos (){


let acumulador = 0;
for (let i = 0; i < 5; i++){
acumulador = acumulador + 0.25
}
return acumulador;
}
ACUMULADOR VARIABLE

function sumarMonedasDe25(cantidadDeMonedas) {
let suma = 0;
for (i = 0; i < cantidadDeMonedas; i++){
suma = suma + 0.25;
}
return suma;
}

SEGUIMOS SUMANDO

function sumaDeLosParesDel0Al(x) {
suma = 0;
for (x; x >= 1; x--){
if (x % 2 ==0){
suma = suma + x;
}
}
return suma;
}

SUMATORIA

function sumatoriaHasta (x){


x = x-1;
suma = 0;
for (x; x >=1; x--){
suma = suma + x;
}
return suma;
}
USAIN BOLT TE NECESITA

function caloriasDeTrote(x){
let calorias = 0;
for ( i = 1; i <= x; i ++){
calorias = calorias + i * 5;
}
return calorias;
}

ARRAYS Y CICLOS:
SUMATORIA PARTE 1

function sumatoriaGananciasSemestre(unSemestre) {
return unSemestre[0] + unSemestre[1] +
unSemestre[2] + unSemestre[3] +
unSemestre[4] + unSemestre[5];
}
console.log (sumatoriaGananciasSemestre [0, 1 ,2]);
console.log (sumatoriaGananciasSemestre [0, 1 ,2, 3]);
console.log (sumatoriaGananciasSemestre [0, 1 ,2, 3, 5]);

SUMATORIA PARTE 2

console.log (gananciaTotal( [2, 3] ));


console.log (gananciaTotal( [2, 3, 1, 8, 8, -1] ));
console.log (gananciaTotal( [] ));
SUMATORIA PARTE 3

function gananciaTotal4(unPeriodo) {
let sumatoria = 0;
sumatoria = sumatoria + unPeriodo[0];
sumatoria = sumatoria + unPeriodo[1];
sumatoria = sumatoria + unPeriodo[2];
sumatoria = sumatoria + unPeriodo[3];
return sumatoria;
}

SUMATORIA PARTE 4

function gananciaTotal(unPeriodo) {
let sumatoria = 0;
for (let i = 0; i < unPeriodo.length; i++) {
let mes = unPeriodo[i];
sumatoria = sumatoria + mes;
}
return sumatoria;
}

console.log(gananciaTotal([]));
console.log(gananciaTotal([100]));
console.log(gananciaTotal([100, 2]));
console.log(gananciaTotal([2, 10, -20]));
console.log(gananciaTotal([2, 10, -20, 0, 0, 10, 10]));
CONTEOS

function cantidadDeMesesConGanancia (unPeriodo) {


let cantidad = 0;
for (let i = 0; i < unPeriodo.length; i++) {
if (unPeriodo[i] > 0){
cantidad += 1;
}

}
return cantidad;

FILTRADOS

function saldosDeMesesConGanancia (periodo){


let saldos = [];
for (let i = 0; i < periodo.length; i ++){ let mes =
periodo [i]; if (mes >0){saldos.push (mes)}
}
return saldos;
}
MAS CONTEOS

function cantidadDeMesesConPerdida(periodo){
let perdida = 0;
for (i = 0; i < periodo.length; i ++){
let meses = periodo [i]
if (meses < 0){
perdida = perdida + 1;
}

}
return perdida
}

JUEGO DE NAIPES

function naipes(palo){
array = []
for (i = 1; i <= 7; i++){
array.push (i + " de " + palo);
}
for (i = 10; i <=12; i++){
array.push (i + " de " + palo);
}
return array;
}
FACTORIAL

function factorial (numero){


if ((numero > 0) & (numero % 1 == 0)){
let factor = 1;
for (let i = 1; i<= numero; i++){
factor = factor * i;
}
return factor;
}else{
return "El numero debe ser positivo y entero";
}

PRODUCTORIA

function productoria(a){
let resultado = 1;
for (i = 0; i < a.length; i++){
resultado = resultado * a[i]
}
return resultado;
}
ARBOL UTOPICO

function alturaArbolUtopico(ciclos){
let resultado = 1;
for (i = 1; i < ciclos +1; i ++){
if (i % 2 == 0){
resultado = resultado + 1;
}else {
resultado = resultado * 2;
}
}
return resultado;
}
MAS | MENOS

function masMenos (array){


let x = array.length;
let cero = 0;
let pos = 0;
let neg = 0;
let porcentajes = [];
for (i = 0; i <= x - 1; i++){
if (array[i] == 0){
cero = cero + 1;
} else if (array [i]> 0){
pos = pos + 1;
} else {
neg = neg +1;
}
}
porcentajes.push(pos/x);
porcentajes.push(cero/x);
porcentajes.push(neg/x);
return porcentajes;
}

También podría gustarte