I am trying to solve this problem but i can't. Would need some help. Thank you.
Write a JavaScript code in a Web page dec2hex.html that enters a positive integer number num and converts and converts it to a hexadecimal form. The input should be entered as JavaScript prompt window. The output should be shown as browser popup window (alert).
My code:
<!DOCTYPE html>
<html>
<head>
<title>Decimal</title>
</head>
<body>
<script type="text/javascript">
var decimal = prompt("Write your decimal number");
var hex = decimal.toString(16);
alert(hex);
</script>
</body>
</html>
Examples:
Input: 254
Output: FE
Input: 6779
Output: 1A7B