You may very well be right :-)
imho, the function signature doesn't count as a LOC... however, in my code I set a default value in a function parameter but then use it as an argument, so I believe have to count it as a line.
The alternative would be:
const bubblie = (arr) => { let swaps = false; arr.forEach((e,i) => { e > arr[i+1] ? ([arr[i], arr[i+1]] = [arr[i+1], arr[i]], swaps = true) : false }); return !swaps ? arr : bubblie(arr, false); }
edit: now that I think about it one more time, I could use the fact that 'undefined' evaluates to false and then it would be just 2 lines of code :-)
const bubblie = (arr, swaps) => { arr.forEach((e,i) => { (e > arr[i+1]) ? ([arr[i], arr[i+1]] = [arr[i+1], arr[i]], swaps = true) : false }); return swaps ? bubblie(arr, false) : arr; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You may very well be right :-)
imho, the function signature doesn't count as a LOC... however, in my code I set a default value in a function parameter but then use it as an argument, so I believe have to count it as a line.
The alternative would be:
edit: now that I think about it one more time, I could use the fact that 'undefined' evaluates to false and then it would be just 2 lines of code :-)