mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-08 12:35:16 +08:00
@ -29,7 +29,7 @@ const hexLookup = (bin) => {
|
||||
}
|
||||
const binaryToHex = (binaryString) => {
|
||||
/*
|
||||
Function for convertung Binary to Hex
|
||||
Function for converting Binary to Hex
|
||||
|
||||
1. The conversion will start from Least Significant Digit (LSB) to the Most Significant Bit (MSB).
|
||||
2. We divide the bits into sections of 4-bits starting from LSB to MSB.
|
||||
|
@ -21,9 +21,9 @@ const RailwayTimeConversion = (timeString) => {
|
||||
return new TypeError('Argument is not a string.')
|
||||
}
|
||||
// split the string by ':' character.
|
||||
const [hour, minute, scondWithShift] = timeString.split(':')
|
||||
const [hour, minute, secondWithShift] = timeString.split(':')
|
||||
// split second and shift value.
|
||||
const [second, shift] = [scondWithShift.substr(0, 2), scondWithShift.substr(2)]
|
||||
const [second, shift] = [secondWithShift.substr(0, 2), secondWithShift.substr(2)]
|
||||
// convert shifted time to not-shift time(Railway time) by using the above explanation.
|
||||
if (shift === 'PM') {
|
||||
if (parseInt(hour) === 12) { return `${hour}:${minute}:${second}` } else { return `${parseInt(hour) + 12}:${minute}:${second}` }
|
||||
|
@ -80,19 +80,19 @@ describe('Testing Conversion of Rankine to Kelvin', () => {
|
||||
expect(test1).toBe(6)
|
||||
})
|
||||
})
|
||||
describe('Testing Conversion of Reamur to Celsius', () => {
|
||||
it('with Reamur value', () => {
|
||||
describe('Testing Conversion of Reaumur to Celsius', () => {
|
||||
it('with Reaumur value', () => {
|
||||
const test1 = tc.reaumurToCelsius(100)
|
||||
expect(test1).toBe(125)
|
||||
})
|
||||
})
|
||||
describe('Testing Conversion of Reamur to Fahrenheit', () => {
|
||||
it('with Reamur value', () => {
|
||||
describe('Testing Conversion of Reaumur to Fahrenheit', () => {
|
||||
it('with Reaumur value', () => {
|
||||
const test1 = tc.reaumurToFahrenheit(100)
|
||||
expect(test1).toBe(257)
|
||||
})
|
||||
})
|
||||
describe('Testing Conversion of Reamur to Kelvin', () => {
|
||||
describe('Testing Conversion of Reaumur to Kelvin', () => {
|
||||
it('with Reamur value', () => {
|
||||
const test1 = tc.reaumurToKelvin(100)
|
||||
expect(test1).toBe(398)
|
||||
|
Reference in New Issue
Block a user