Created
September 7, 2018 12:31
-
-
Save ippaiva/e18985cd1f1d5e7824367c55475dfea2 to your computer and use it in GitHub Desktop.
PoliticalGeneralQuote created by ippaiva - https://repl.it/@ippaiva/PoliticalGeneralQuote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//var.obj | |
var carro= { | |
rodas: 4, | |
motor: 1, | |
espelho: 2, | |
cor: "Azul", | |
ar: true | |
} | |
//ES6 | |
var carro2 = {...carro} | |
carro.espelho -= 1; // acidente | |
console.log(carro) ///depois acidente | |
//var lista | |
var lista = [1,2,3, "hello"]; | |
console.log(lista[3]) | |
//var obj + lista | |
var school = { | |
name: "Ironhack", | |
classroom: [ | |
{teacher: "Mateus", students: ["Pedro", "Ismael"]}, | |
{teacher: "Mateus", students: ["Pedro", "Nathalia","Ismael"]}, | |
{teacher: "Mateus", students: ["Pedro", "Ismael"]} | |
] | |
} | |
var obj = school.classroom[1]; | |
console.log(obj.students[2]); | |
//lacos de repeticao | |
for(var i=0; i < school.classroom.length; i++){ | |
//console.log(school.classroom[i]); | |
} | |
//var lista = [0,1,2,3,4,5]; | |
//console.log("qtde de elementos " + lista.length); | |
var n1 = 5; | |
var n2 = 10; | |
//condições | |
if(n1 > n2){ | |
console.log(n1); | |
} | |
else if(n1 + n2 > 14){ | |
console.log("Yes!"); | |
} | |
else{ | |
console.log(n2); | |
} | |
//remaider | |
console.log(6%3) //mostra o resto da divisão (neste caso = 0) | |
//conte até 100 | |
/*for (i=0; i <=100; i++){ | |
console.log(i); | |
}*/ | |
//quando o numero for numero de 3 | |
//print "Iron" | |
for(var i= 1; i<=100 ;i++) | |
if(i % 3 == 0){ | |
//console.log("Iron"); | |
}else{ | |
//console.log(i); | |
} | |
//multiplos de 3 | |
var num =[]; | |
for(var i= 1; i<=100 ;i++) | |
if(i % 3){ | |
num.push(i); | |
console.log("Iron"); | |
}else{ | |
console.log(i); | |
} | |
console.log(num); | |
//funções | |
var gps = { | |
x: 0, | |
y: 0, | |
logPos:[] | |
} | |
function addList(obj, valX){ | |
obj.logPos.push(valX) | |
} | |
function goRigth(algumaCoisa){ | |
algumaCoisa.x++; | |
addList(algumaCoisa) | |
} | |
function goLeft(algumaCoisa){ | |
algumaCoisa.x--; | |
} | |
console.log(gps); | |
goRigth(gps); | |
goLeft(gps); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aula JS. Mateus Ironhack