I've just started to learn JavaScript and got a pretty basic question.
Im going to create a function I call 'printAnyRange()' that takes two arguments: 'rangeStart' and 'rangeStop'. I want this to return a string with alla numbers comma-seperated in the range.
If 'rangeStart' is smaller than 'rangeStop' it should call the function 'printRange()'. If 'rangeStart' is greater than 'rangeStop' it should call the function 'printRangeReversed()'.
My question is, should I use a 'for-loop' to do this or would it be better with 'if..else'?
Aucun commentaire:
Enregistrer un commentaire