Generic Distance Calculator Service Component in Lightning Web Component
In this scenario, You are going to work on writing a service component in Lightning Web Component to calculate distance between two coordinates when location coordinates are passed to it as parameter. This service component should be called from some other Lightning Web Component which has input location component.
This problem statement has been designed for developer who are Intermediate in Lightning Web Component.
Service Lightning Web Component
- Create a service component which exports a function
- The exported function should accept two different location coordinates
- The distance calculator function should return the distance in miles between two coordinates
Main Lightning Web Component
- Create a Lightning Web Component
- It should have two input-location
- Import the service component and its function
- Call the function on a button click whose label is calculate distance
- You should pass these location coordinates to distance calculator function
- Show the result on UI
Do you need help?
Are you stuck while working on this requirement? Do you want to get review of your solution? Now, you can book dedicated 1:1 with me on Lightning Web Component completely free.
GET IN TOUCH
Schedule a 1:1 Meeting with me
Do not forget to paste your code in comment for this scenario. It would help others in case they get stuck. Also check out https://salesforcediaries.com/category/lightning-web-component/ to learn more on LWC.