Here's a basic example of how to create a Svelte page that calculates the weight of an object on different planets based on their respective gravity:
1392 chars60 lines
In this example, we have an array of planets with their respective gravity values. We also have an input field for the user to enter the weight of the object they want to calculate the weight for. The calculateWeight()
function takes the gravity of the planet and calculates the weight of the object on that planet in newtons, using the formula force = mass x gravity
. The weight is then displayed on the page for each planet in newtons.
gistlibby LogSnag