Improved Advanced Code Solution (#22898)

This way it is less confusing + people should be aware of slice default arguments
This commit is contained in:
VitBu
2018-11-29 04:01:42 +02:00
committed by Christopher McCormack
parent 6b2f72cae5
commit d16c9b58fd

View File

@ -73,13 +73,13 @@ If you still can't figure out how to solve it with shift, then try solving it wi
## ![:sunflower:](https://forum.freecodecamp.com/images/emoji/emoji_one/sunflower.png?v=3 ":sunflower:") Intermediate Code Solution:
function dropElements(arr, func) {
return arr.slice(arr.findIndex(func) >= 0 ? arr.findIndex(func): arr.length, arr.length);
return arr.slice(arr.findIndex(func) >= 0 ? arr.findIndex(func): arr.length);
}
// test here
dropElements([1, 2, 3, 4], function(n) {return n >= 3;});
![:rocket:](https://forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=3 ":rocket:") <a href='https://repl.it/CLnc/0' target='_blank' rel='nofollow'>Run Code</a>
![:rocket:](https://forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=3 ":rocket:") <a href='https://repl.it/repls/PositiveSandyObjectcode' target='_blank' rel='nofollow'>Run Code</a>
### Code Explanation: