Created
July 30, 2017 13:05
-
-
Save imorte/16d3e575750fb5610815461887c309d3 to your computer and use it in GitHub Desktop.
Revisions
-
imorte created this gist
Jul 30, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ /** * Created by kirill on 30/07/2017. */ array = [1, 2, 3, 4]; function rec_sum(array) { if(array.length > 1) { return array[0] + rec_sum(array.slice(1)) } else { return array[0]; } } console.log(rec_sum(array));