Skip to content

Instantly share code, notes, and snippets.

@seonatic
Created June 27, 2018 13:32
Show Gist options
  • Save seonatic/b95f983f5a0eef22ae3bdbfbc6adb21e to your computer and use it in GitHub Desktop.
Save seonatic/b95f983f5a0eef22ae3bdbfbc6adb21e to your computer and use it in GitHub Desktop.

Revisions

  1. seonatic created this gist Jun 27, 2018.
    69 changes: 69 additions & 0 deletions index.html
    Original 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>
    27 changes: 27 additions & 0 deletions jsbin.darilaz.js
    Original 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);