I am a complete newbie. But I am working on a piece of training code and hit a wall. I completed the project, however, I wanted to test an additional piece of code. I want to use string interpolation to show the user a message like this:
If this object were on ${planetName} it would weight ${thisMuch}.
But I am confused on how to call only one argument from a function with two parameters.
function calculateWeight(earthWeight, planet) {
let weight;
if(planet === 'Mercury') {
weight = earthWeight * .378
return `${weight}`
}if(planet === 'Venus') {
weight = earthWeight * .907
return `${weight}`
}if(planet === 'Mars') {
weight = earthWeight * .377
return `${weight}`
}if(planet === 'Jupiter') {
weight = earthWeight * 2.36
return `${weight}`
}if(planet === 'Saturn') {
weight = earthWeight * 0.916
return `${weight}`
} else {
return 'Invalid Planet Entry. Try: Mercury, Venus, Mars, Jupiter, or Saturn.'
}
}
// Uncomment the line below when you're ready to try out your function
console.log(calculateWeight(100, 'Jupiter'))