Create HexToDecimal.js #274
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
Explanation:
1 - It takes the number and converts it to an array
2 - Then the letters inside this array are converted to decimal numbers and it's returned by the first function (an array of integers)
3 - Reduce is applied to multiply each item of the array of integers by the base 16, raised to its respective pow, and make a sum of these multiplications.
Example:
1 - ['E', '5', 'D', '4' ]
2 - [14, 5, 13, 4]
3 - 14 * 16³ + 5 * 16² + 13 * 16¹ + 4 * 16⁰ = 58836
Hope this can be useful to conversions in JavaScript repository :)
Welcome to JavaScript community
Describe your change:
Checklist:
Example:
UserProfile.js
is allowed butuserprofile.js
,Userprofile.js
,user-Profile.js
,userProfile.js
are notFixes: #{$ISSUE_NO}
.