+ 5

JS_ how to do this ...

var P = 0; Var days = 100; As you can see I don't have the full code to make a countdown timer But the days start from 100. So when it is day 99, P = 1; Day 98, P = 2; Day 97, P = 3; Day 96, P = 4; ....... So on. Instead of listing them like that, how do you do it the simple way __ to increase P by 1, as Days decreases by 1 ??

10th Aug 2019, 12:15 AM
Ginfio
Ginfio - avatar
7 Respostas
+ 10
Ginfio I've modified my original code to do what you're looking for. NOTE: It's not that you're being too picky. However, being able to clearly explain what you're looking for is tremendously important. 😉 Also, even though the codes provided may not perfectly match what you needed, much of the difficult parts are completed in these codes. You can always put together the rest using the existing logic. This is part of the learning process. 🤓 Counter Using Generator: https://code.sololearn.com/WFrvsK2rWpmj/?ref=app Another Counter Using Decrement--: https://code.sololearn.com/WF0UBhyW3mMI/?ref=app
10th Aug 2019, 6:30 AM
David Carroll
David Carroll - avatar
+ 7
[UPDATED] Ginfio Here's a version using a generator function that's called once every second to print the values where seconds decrement while p increments. https://code.sololearn.com/WFrvsK2rWpmj/?ref=app
10th Aug 2019, 5:51 AM
David Carroll
David Carroll - avatar
+ 4
Ok, i might be being too picky, or not explaining it correct. The codes you guyz showed me, they print the numbers as _ umm, i donno. You know when a watch counts, the 2 disappears then, 3 comes on, 3 disappears, 4 comes < like that. So we got P on one side increasing 1 disappear, 2 appear on 1, (like watch counting). Otherside the countdown. I appriciate your try though!
10th Aug 2019, 6:04 AM
Ginfio
Ginfio - avatar
+ 3
You can incorporate an interval if you want to delay it by a fixed time https://code.sololearn.com/WgB1SEoZjp4c/?ref=app
10th Aug 2019, 12:59 AM
Jake
Jake - avatar
+ 2
if i understand well, i think you can just use a FOR loop, like that: var P=0; var days=100; for(let i=1; i<=100; i++) { console.log(P++); console.log(days--); //or alert(P++); alert(days--); }
10th Aug 2019, 12:40 AM
Régy Mintyene
Régy Mintyene - avatar
+ 2
David Carroll ok. Thank You.
10th Aug 2019, 3:16 PM
Ginfio
Ginfio - avatar
+ 1
Cbr✔[ Not Active ] , kind of. But i don't want print all of them at the same time. Let's do it with Seconds instead of Days. So, countdown timer, 60 counts. As it counts down( 59, 58, 57, 56,...)., Increase P. (1, 2, 3, 4...).
10th Aug 2019, 12:37 AM
Ginfio
Ginfio - avatar