<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Explode 3</title>
</head>
<body>
<input type="text" name="" id="given_digit">
<button onclick="explode()">Click to split</button>
<div id="result"></div>
<script>
function explode(){
var number = document.getElementById('given_digit').value;
number = parseInt(number);
var remainder;
var counter = 0;
if (isNaN(number)){
remainder = "You have to Enter number value";
} else {
while(number > 0){
counter++;
if(remainder == undefined){
remainder = number % 10;
} else {
remainder = (number % 10) +"<br> "+ remainder ;
}
number = parseInt(number / 10);
}
}
remainder = remainder + "<br> Total number of digit you've entered: <br>" + counter;
document.getElementById('result').innerHTML = remainder;
}
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Explode 3</title>
</head>
<body>
<input type="text" name="" id="given_digit">
<button onclick="explode()">Click to split</button>
<div id="result"></div>
<script>
function explode(){
var number = document.getElementById('given_digit').value;
number = parseInt(number);
var remainder;
var counter = 0;
if (isNaN(number)){
remainder = "You have to Enter number value";
} else {
while(number > 0){
counter++;
if(remainder == undefined){
remainder = number % 10;
} else {
remainder = (number % 10) +"<br> "+ remainder ;
}
number = parseInt(number / 10);
}
}
remainder = remainder + "<br> Total number of digit you've entered: <br>" + counter;
document.getElementById('result').innerHTML = remainder;
}
</script>
</body>
</html>
No comments:
Post a Comment