Day 90: Count Up Using Recursion of 100DaysCodingChallenge
Hello all,
#day90
Day90
Today's task was to write a program that will give a countdown of numbers in ascending order upto to the number 10.
lower number input entered by the user.
Example:
from 1 up to 10.
Sample Input: 1
Sample Output: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
here, I have taken another input number randomly from the range of between 1 to 10 by myself.
I have started the 100 days of coding challenge to improve my programming skills..
Code :
let a = prompt("Enter a Number : ");
// program to count down numbers to 1
function countUp(number) {
// display the number
console.log(number);
// decrease the number value
//const newNumber = number + 1;
// base case
if (number < 10) {
//countDown(newNumber);
return countUp(number + 1);
}
return 0;
}
//countDown(4);
countUp(parseInt(a));
Output :
Happy Coding:)
Thank you...

Comments
Post a Comment