+ 1
Can you make it shorter?? JS
Presentation should be same https://code.sololearn.com/Ws1GmfIjDLAJ/?ref=app
5 Answers
+ 2
Himansh this might be shorter and it follows the maximum condition as well.
let a = ['1st','2nd','3rd','4th','5th'], r = 1, i = prompt ("How many times you want to show alert message (max: 5)")
while (r <= a.length && r <= i){
alert(a[r-1])
++r
}
+ 3
Himansh
Use array instead of Hard Code checking
var arr = ['1st', '2nd', '3rd', '4th', '5th'];
for (let r = 1, i = prompt("How many times you want to show alert message (max:5)"); r <= i; r++) {
alert(arr[r - 1]);
};
+ 2
for (let r=1, i=prompt("How many times you want to show alert message (max:5)"); r <= i && r <= 5; r++) alert(['1st', '2nd', '3rd', '4th', '5th'][r-1]);
+ 2
I worked with the code and made this
https://code.sololearn.com/WYaWVEXb1oo3/?ref=app
+ 1
A͢J - SÍoÍlÍoÍHÍeÍlÍpÍeÍrÍ Art1mis Both answers are really to the point and I don't think there may be more shorter way to do so! đ