Skip to content

Instantly share code, notes, and snippets.

@DavidPeralvarez
Created April 3, 2020 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidPeralvarez/ca1a888763d7de895f9321e761014ed8 to your computer and use it in GitHub Desktop.
Save DavidPeralvarez/ca1a888763d7de895f9321e761014ed8 to your computer and use it in GitHub Desktop.
JavaScript - Operador condicional ternario
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Curso de Javascript</title>
</head>
<body>
<script src="scripts.js"></script>
</body>
</html>
var tengoSalmon = true,
tengoAlgaNori = true,
tengoArroz = true;
function maquisSalmon( salmon, alga, arroz ){
// if ( salmon && alga && arroz ) {
// return 'Puedo hacer maquis.';
// } else {
// return 'No puedo hacer maquis.';
// }
return ( salmon && alga && arroz ) ? 'Puedo hacer maquis.' : 'No puedo hacer maquis.';
}
console.log( maquisSalmon( tengoSalmon, tengoAlgaNori, tengoArroz ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment