Skip to content

Instantly share code, notes, and snippets.

@Jorger
Created September 19, 2018 16:17
Show Gist options
  • Save Jorger/78ba02149fe5941b609496623d1ff79b to your computer and use it in GitHub Desktop.
Save Jorger/78ba02149fe5941b609496623d1ff79b to your computer and use it in GitHub Desktop.
// source https://jsbin.com
<!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>
//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