Algorithm of frying => fried chicken
Download 1.64 Kb.
|
Документ
// input => algorithm => output // indgridients => algorithm of frying => fried chicken // DRY – don't repeat yourself /* algorithm of frying chicken: 1. put utensil on the stove 2. put oil 5. fry */
const bottleOfOil = 'oil'; let onStove = null; let timer = 10; const utensil = 'kazan'; function putOnStove(dish) { if (onStove === null) { onStove = dish; console.log(`${dish} is on the stove`); } else { console.log('the stove is occupied'); } }
if (onStove !== null) { onStove = null; console.log('the stove is empty now'); } else {
console.log('the stove is already empty'); } } putOnStove(utensil); //emptyStove(); putOnStove('pan'); function chop(indgridient) { console.log(indgridient + 'is chopped'); return `chopped ${indgridient}`; } //function function fry() { putOnStove(utensil); for (const indgridient in boxOfVeggies) { const chopped = chop(indgridient); console.log(`${chopped} started frying`); } } Download 1.64 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling