# JavaScript Int to Hex converter and Universal base converter!

## JavaScript Integer to Hex Converter

A simple Hex to Integer converter that I wrote using JavaScript.

Int -> Hex: | ||

Hex -> Int: |

## JavaScript universal base converter!

I thought I'd have some fun and create a universal converter

From base: | ||

To base: | ||

Base 10 -> 2: | ||

Base 2 -> 10: |

This code is pretty simple. Here's the main function:

function baseToBase (fromBase, toBase, value) {; if(value=="") value = 0; value = parseInt(value, fromBase); return Number(value).toString(toBase).toUpperCase(); }

It just uses JavaScript's parse int to convert the from field into a decimal. Then it uses the toString method to covert this decimal to the correct base. The rest of the code (which can be seen by looking at the source) is just involves some jQuery calls to get the boxes working together.

## Add new comment