Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,29 @@
let dogsAgeAsNumber = parseInt(dogsAge);

function getHumanAge (dogsAge) {
return parseInt(dogsAge) * 7;
let result = parseInt(dogsAge) * 7;

// if the dogsAge was 0 then the result is also 0
//then we want to return 'A puppy less than 1'
// condition / predicate
// other ways to check conditions: < > <= >= == === != !==
if (result == 0) {

// code here runs when condition about is met
result = 'A puppy less than 1 year';

}

return result;

}

let humanAge1 = getHumanAge(dogsAge);
let humanAge2 = getHumanAge(23);
let humanAge3 = getHumanAge(12);
let humanAge4 = getHumanAge(0);

console.log({humanAge1, humanAge2, humanAge3});
console.log({humanAge1, humanAge2, humanAge3, humanAge4});

</script>

Expand Down