Created
March 10, 2019 03:13
-
-
Save jack-guy/2099d643b77ba472570425a55a17c531 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getIceCreamFlavorToPrice(flavors, prices) { | |
let iceCreamFlavorToPrice; | |
for (let i = 0; i < flavors.length; i++) { | |
iceCreamFlavorToPrice[flavors[i]] = prices[i]; | |
} | |
return iceCreamFlavorToPrice; | |
} | |
let iceCreamFlavors = ['vanilla', 'chocolate', 'strawberry']; | |
let iceCreamPrices = ['$5.50', '$5.75', '$6.00']; | |
let iceCreamFlavorToPrice = getIceCreamFlavorToPrice(iceCreamFlavors, iceCreamPrices); | |
formEl.addEventListener('submit', (formData) => { | |
iceCreamFlavors.push(formData.flavor); | |
iceCreamPrices.push(formData.price); | |
iceCreamFlavorToPrice = getIceCreamFlavorToPrice(iceCreamFlavors, iceCreamPrices); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment