Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 32f1e33

Browse files
ddhira123raklaptudirm
andauthored
merge: Added Hex to Binary conversion (#805)
* Added Hex to Binary conversion * Update Conversions/HexToBinary.js Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com> * Update Conversions/HexToBinary.js Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com> * Update Conversions/HexToBinary.js Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com> * Update Conversions/HexToBinary.js Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com> * Fix errors * fix: typo Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com>
1 parent d19108b commit 32f1e33

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

‎Conversions/HexToBinary.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@ const binLookup = (c) => {
2121
}
2222
const hexToBinary = (hexString) => {
2323
/*
24-
Function for convertung Hex to Binary
24+
Function for converting Hex to Binary
2525
2626
1. We convert every hexadecimal bit to 4 binary bits
2727
2. Conversion goes by searching in the lookup table
2828
2929
*/
30-
31-
let result = ''
32-
hexString = hexString.split('')
33-
hexString.forEach(c => { result += binLookup(c) })
34-
return result
30+
const hexLexemes = hexString.split('')
31+
return hexLexemes.map(lexeme => binLookup(lexeme)).join('')
3532
}
3633

3734
export default hexToBinary

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /