Created
June 27, 2018 13:32
-
-
Save seonatic/b95f983f5a0eef22ae3bdbfbc6adb21e to your computer and use it in GitHub Desktop.
Revisions
-
seonatic created this gist
Jun 27, 2018 .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,69 @@ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>JS Bin</title> </head> <body> <script id="jsbin-javascript"> function Person (name, age) { this.name= name; this.age= age; this.getInfo = function(){ console.log(this.name + ' ' + this.age); } } var jam = new Person ('James', 22); jam.getInfo(); let arr = [ 1,3,6,2,4,5,7,8,10]; let sorted = arr.sort( (a,b) => a - b); var x = sorted.find(el => el - 1 !== sorted.indexOf(el))-1; console.log (x); let arr2 = [ 1,3,6,2,4,5,7,8,10]; var b= arr2.reduce (( acc, item) => acc+item); var n= arr2.length+1; var total= (n*(n+1))/2; console.log(total-b); </script> <script id="jsbin-source-javascript" type="text/javascript">function Person (name, age) { this.name= name; this.age= age; this.getInfo = function(){ console.log(this.name + ' ' + this.age); } } var jam = new Person ('James', 22); jam.getInfo(); let arr = [ 1,3,6,2,4,5,7,8,10]; let sorted = arr.sort( (a,b) => a - b); var x = sorted.find(el => el - 1 !== sorted.indexOf(el))-1; console.log (x); let arr2 = [ 1,3,6,2,4,5,7,8,10]; var b= arr2.reduce (( acc, item) => acc+item); var n= arr2.length+1; var total= (n*(n+1))/2; console.log(total-b);</script></body> </html> 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,27 @@ function Person (name, age) { this.name= name; this.age= age; this.getInfo = function(){ console.log(this.name + ' ' + this.age); } } var jam = new Person ('James', 22); jam.getInfo(); let arr = [ 1,3,6,2,4,5,7,8,10]; let sorted = arr.sort( (a,b) => a - b); var x = sorted.find(el => el - 1 !== sorted.indexOf(el))-1; console.log (x); let arr2 = [ 1,3,6,2,4,5,7,8,10]; var b= arr2.reduce (( acc, item) => acc+item); var n= arr2.length+1; var total= (n*(n+1))/2; console.log(total-b);