Created
September 19, 2018 16:17
-
-
Save Jorger/78ba02149fe5941b609496623d1ff79b to your computer and use it in GitHub Desktop.
// source https://jsbin.com
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
//Opción Uno... | |
var mensaje = [true, true, true, true, true]; | |
for(var i = 0, total = 0; i < mensaje.length; i++) { | |
total += +mensaje[i]; | |
} | |
if(total === mensaje.length) { | |
console.log("TODOS ESTÁN EN TRUE"); | |
} | |
//Opción dos (ES6)... | |
const mensaje2 = [true, true, true, true, true]; | |
if(mensaje2.reduce((a, s) => a + (+s), 0) === mensaje2.length) { | |
console.log("TODOS ESTÁN EN TRUE"); | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">//Opción Uno... | |
var mensaje = [true, true, true, true, true]; | |
for(var i = 0, total = 0; i < mensaje.length; i++) { | |
total += +mensaje[i]; | |
} | |
if(total === mensaje.length) { | |
console.log("TODOS ESTÁN EN TRUE"); | |
} | |
//Opción dos (ES6)... | |
const mensaje2 = [true, true, true, true, true]; | |
if(mensaje2.reduce((a, s) => a + (+s), 0) === mensaje2.length) { | |
console.log("TODOS ESTÁN EN TRUE"); | |
}</script></body> | |
</html> |
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
//Opción Uno... | |
var mensaje = [true, true, true, true, true]; | |
for(var i = 0, total = 0; i < mensaje.length; i++) { | |
total += +mensaje[i]; | |
} | |
if(total === mensaje.length) { | |
console.log("TODOS ESTÁN EN TRUE"); | |
} | |
//Opción dos (ES6)... | |
const mensaje2 = [true, true, true, true, true]; | |
if(mensaje2.reduce((a, s) => a + (+s), 0) === mensaje2.length) { | |
console.log("TODOS ESTÁN EN TRUE"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment