Presentation comments ...
--- ## Code reuse This is the code from the previous lesson. This code runs just once. ```js let apples = 2; if (apples > 3) { console.log(`We have ${apples} apples! We can make pie!`) } else { console.log(`We have ${apples} apples! We need more apples`) } // -> "We have 2 apples! We need more fruit." ``` --- ## Code reuse <div class="twocolumn"> <div class="col"> Wrapping this code inside a function lets us... 1. Run the code multiple times with different values 1. Change the value that determines the logical flow </div> <div class="col"> ```js function canPie(fruit, count){ let str = `We have ${count} ${fruit}! `; if (count > 3) { str += `We can make pie!`; } else { str += `We need more fruit.`; } return str; } console.log(`${canPie("apples", 2)}`); // -> "We have 2 apples! We need more fruit." console.log(`${canPie("pears", 5)}`); // -> "We have 5 pears! We can make pie!" console.log(`${canPie("berries", 101)}`); // -> "We have 101 berries! We can make pie!" ``` </div> </div>