Kata of the Day #17

Hex to Decimal

kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
Kata of the Day #17

Complete the function which converts hex number (given as a string) to a decimal number.

TypeScript


function hexToDec(hexString: string):number{
    return parseInt(hexString, 16);
}

console.log(hexToDec("FF"));

Go


package main

import (
	"fmt"
	"strconv"
)

func hexToDec(hexString string) int64 {
	decimal, _ := strconv.ParseInt(hexString, 16, 32)
	return decimal
}

func main() {
	fmt.Println(hexToDec("FF"))
}

Python


def hex_to_dec(hexString):
    return int(hexString, 16)

print(hex_to_dec("FF"))

PHP


function hexToDec($hexString) {
    return hexdec($hexString);
}

echo hexToDec("FF");

Go to Kata
ByCesar Kohl

Need some help?

Want us to give you some help with your business? No problem, here's a video on who we can help, and how, along with our calendar so you can book in a call to discuss us working together.

Let's see
budget
budget
budget
budget
budget
budget
budget
budget
budget
budget

Subscribe to our newsletter

subscribe
subscribe
subscribe
subscribe
subscribe
subscribe
subscribe
subscribe
subscribe
subscribe