From edc962bed51b44eb8fca4f1a844ccdcbc26e8ae8 Mon Sep 17 00:00:00 2001 From: Yor Name Date: Wed, 10 Jun 2020 21:31:16 -0400 Subject: [PATCH] including a branching example --- index.html | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 0507031..f596c69 100644 --- a/index.html +++ b/index.html @@ -14,14 +14,23 @@ let dogsAgeAsNumber = parseInt(dogsAge); function getHumanAge (dogsAge) { - return parseInt(dogsAge) * 7; - } + let result = (parseInt(dogsAge)*7); - let humanAge1 = getHumanAge(dogsAge); - let humanAge2 = getHumanAge(23); - let humanAge3 = getHumanAge(12); + // if the dogsAge was 0 then result is also 0 + // then we want to return 'A puppy less than 1' + if(result==0) { + result = 'A puppy less than 1'; + } - console.log({humanAge1, humanAge2, humanAge3}); + + return result; } + + + + let humanAges = []; + humanAges.push(getHumanAge(dogsAge),getHumanAge(23), getHumanAge(12), getHumanAge(0)); + + console.log({humanAges});