Skip to content

Instantly share code, notes, and snippets.

@flleeppyy
Created April 26, 2022 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flleeppyy/79e036d784acf84b8149a90fa0ceb33d to your computer and use it in GitHub Desktop.
Save flleeppyy/79e036d784acf84b8149a90fa0ceb33d to your computer and use it in GitHub Desktop.
const secsArray = [
5.2,
6.0,
2.8,
10.0,
3.6,
8.0,
15.0,
11.5,
1.5,
9.5,
];
const speedOfSound = 1500;
const alphabet = "abcdefghijklmnopqrstuvwxyz";
const formula = (echoTime, speedOfSound) => {
return (echoTime * speedOfSound) / 2;
}
for (let i = 0; i < secsArray.length; i++) {
const echoTime = secsArray[i];
const distance = formula(echoTime, speedOfSound);
console.log(`${alphabet[i]}: ${distance}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment