First init

This commit is contained in:
gauvainboiche
2025-07-08 11:23:22 +02:00
commit 6a18c3851c
61 changed files with 2046 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
// Write your function here:
function calculateWeight(earthWeight, planet) {
if (!Number.isInteger(earthWeight)) {
return("Please enter an integer for weight.");
}
if (typeof planet !== "string") {
return("Please enter a string for planet.");
}
switch (planet) {
case "Mercury" :
return earthWeight * 0.378;
case "Venus" :
return earthWeight * 0.907;
case "Mars" :
return earthWeight * 0.377;
case "Jupiter" :
return earthWeight * 2.36;
case "Saturn" :
return earthWeight * 0.916;
default :
return("Invalid Planet Entry. Try: Mercury, Venus, Mars, Jupiter, or Saturn.");
}
}
console.log(calculateWeight(100, "Camembert"));
// Uncomment the line below when you're ready to try out your function
// console.log(calculateWeight(100, 'Jupiter')) // Should print 236
// We encourage you to add more function calls of your own to test your code!