mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 09:28:26 +08:00

* chore: remove codespell from ci * feat: add codespell workflow * fix: codespell workflow * fix: ignore spellings in directory * chore: fix spellings ./Dynamic-Programming/KadaneAlgo.js:2: contiguos ==> contiguous ./Dynamic-Programming/KadaneAlgo.js:14: posible ==> possible * chore: fix spelling ./Dynamic-Programming/SieveOfEratosthenes.js:4: upto ==> up to * chore: fix spellings ./Dynamic-Programming/MaxNonAdjacentSum.js:22: Exmaple ==> Example * chore: fix spelling ./Project-Euler/test/Problem010.test.js:4: upto ==> up to ./Project-Euler/test/Problem010.test.js:8: upto ==> up to ./Project-Euler/test/Problem010.test.js:12: upto ==> up to * chore: fix spelling ./String/AlphaNumericPalindrome.js:10: recieves ==> receives ./String/AlphaNumericPalindrome.js:10: sting ==> string ./String/AlphaNumericPalindrome.js:46: varaible ==> variable * chore: fix spelling ./String/DiceCoefficient.js:3: stings ==> strings * chore: fix spelling ./String/test/DiceCoefficient.test.js:9: atleast ==> at least * chore: fix spelling ./String/test/MaxWord.test.js:8: ba ==> be * chore: ignore `PermutateString.test.js` * chore: fix spelling ./String/test/CheckVowels.test.js:62: occurances ==> occurrences * chore: ignore `SubsequenceRecursive.js` * chore: fix spelling ./Conversions/TemperatureConversion.js:2: arguement ==> argument * chore: fix spelling ./Conversions/RailwayTimeConversion.js:7: Formate ==> Format ./Conversions/RailwayTimeConversion.js:8: Formate ==> Format * chore: remove Linear Algebra The deleted directory hosted a package which are not accepted by this repository. * Auto-update DIRECTORY.md * chore: fix spelling * chore: fix spellings * merge: Created composite Simpson's integration method. Tests included. (#819) * Created composite Simpson's integration method.Tests included * Minor corrections * Auto-update DIRECTORY.md * Styled with standard.js * chore: remove blank line * chore: remove blank line Co-authored-by: ggkogkou <ggkogkou@ggkogkou.gr> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com> * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: remove codespell from ci * feat: add codespell workflow * fix: codespell workflow * fix: ignore spellings in directory * chore: fix spellings ./Dynamic-Programming/KadaneAlgo.js:2: contiguos ==> contiguous ./Dynamic-Programming/KadaneAlgo.js:14: posible ==> possible * chore: fix spelling ./Dynamic-Programming/SieveOfEratosthenes.js:4: upto ==> up to * chore: fix spellings ./Dynamic-Programming/MaxNonAdjacentSum.js:22: Exmaple ==> Example * chore: fix spelling ./Project-Euler/test/Problem010.test.js:4: upto ==> up to ./Project-Euler/test/Problem010.test.js:8: upto ==> up to ./Project-Euler/test/Problem010.test.js:12: upto ==> up to * chore: fix spelling ./String/AlphaNumericPalindrome.js:10: recieves ==> receives ./String/AlphaNumericPalindrome.js:10: sting ==> string ./String/AlphaNumericPalindrome.js:46: varaible ==> variable * chore: fix spelling ./String/DiceCoefficient.js:3: stings ==> strings * chore: fix spelling ./String/test/DiceCoefficient.test.js:9: atleast ==> at least * chore: fix spelling ./String/test/MaxWord.test.js:8: ba ==> be * chore: ignore `PermutateString.test.js` * chore: fix spelling ./String/test/CheckVowels.test.js:62: occurances ==> occurrences * chore: ignore `SubsequenceRecursive.js` * chore: fix spelling ./Conversions/TemperatureConversion.js:2: arguement ==> argument * chore: fix spelling ./Conversions/RailwayTimeConversion.js:7: Formate ==> Format ./Conversions/RailwayTimeConversion.js:8: Formate ==> Format * chore: remove Linear Algebra The deleted directory hosted a package which are not accepted by this repository. * Auto-update DIRECTORY.md * chore: fix spelling * chore: fix spellings * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: no need to check filenames Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: ggkogkou <76820848+ggkogkou@users.noreply.github.com> Co-authored-by: ggkogkou <ggkogkou@ggkogkou.gr>
103 lines
3.8 KiB
JavaScript
103 lines
3.8 KiB
JavaScript
// This files has functions to convert different temperature units
|
|
// Functions take temperature value as a argument and returns corresponding converted value
|
|
|
|
const celsiusToFahrenheit = (celsius) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
|
|
return Math.round(((celsius) * 9 / 5) + 32)
|
|
}
|
|
|
|
const celsiusToKelvin = (celsius) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
|
|
return Math.round((celsius) + 273.15)
|
|
}
|
|
|
|
const celsiusToRankine = (celsius) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
|
|
return Math.round(((celsius) * 9 / 5) + 491.67)
|
|
}
|
|
|
|
const fahrenheitToCelsius = (fahrenheit) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
|
|
return Math.round(((fahrenheit) - 32) * 5 / 9)
|
|
}
|
|
|
|
const fahrenheitToKelvin = (fahrenheit) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
|
|
return Math.round((((fahrenheit) - 32) * 5 / 9) + 273.15)
|
|
}
|
|
|
|
const fahrenheitToRankine = (fahrenheit) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
|
|
return Math.round((fahrenheit) + 459.67)
|
|
}
|
|
|
|
const kelvinToCelsius = (kelvin) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
|
|
return Math.round((kelvin) - 273.15)
|
|
}
|
|
|
|
const kelvinToFahrenheit = (kelvin) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
|
|
return Math.round((((kelvin) - 273.15) * 9 / 5) + 32)
|
|
}
|
|
|
|
const kelvinToRankine = (kelvin) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
|
|
return Math.round(((kelvin) * 9 / 5))
|
|
}
|
|
|
|
const rankineToCelsius = (rankine) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
|
|
return Math.round(((rankine) - 491.67) * 5 / 9)
|
|
}
|
|
|
|
const rankineToFahrenheit = (rankine) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
|
|
return Math.round((rankine) - 459.67)
|
|
}
|
|
|
|
const rankineToKelvin = (rankine) => {
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
|
|
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
|
|
return Math.round(((rankine) * 5 / 9))
|
|
}
|
|
|
|
const reaumurToKelvin = (reaumur) => {
|
|
// Reference:- http://www.csgnetwork.com/temp2conv.html
|
|
return Math.round(((reaumur) * 1.25 + 273.15))
|
|
}
|
|
|
|
const reaumurToFahrenheit = (reaumur) => {
|
|
// Reference:- http://www.csgnetwork.com/temp2conv.html
|
|
return Math.round(((reaumur) * 2.25 + 32))
|
|
}
|
|
|
|
const reaumurToCelsius = (reaumur) => {
|
|
// Reference:- http://www.csgnetwork.com/temp2conv.html
|
|
return Math.round(((reaumur) * 1.25))
|
|
}
|
|
|
|
const reaumurToRankine = (reaumur) => {
|
|
// Reference:- http://www.csgnetwork.com/temp2conv.html
|
|
return Math.round(((reaumur) * 2.25 + 32 + 459.67))
|
|
}
|
|
|
|
export {
|
|
celsiusToFahrenheit, celsiusToKelvin, celsiusToRankine,
|
|
fahrenheitToCelsius, fahrenheitToKelvin, fahrenheitToRankine,
|
|
kelvinToCelsius, kelvinToFahrenheit, kelvinToRankine,
|
|
rankineToCelsius, rankineToFahrenheit, rankineToKelvin,
|
|
reaumurToCelsius, reaumurToFahrenheit, reaumurToKelvin, reaumurToRankine
|
|
}
|