1. Simple Array Sum

    function simpleArraySum(ar) { /* * Write your code here. */ var n= ar.length; var x= 0; var i; if(n>0&n<=1000){ for(i=0;i<=n-1;i++){ x+=ar[i]; } return x; } }

  2. Combare Triplets function

    function compareTriplets(a, b) { var n= a.length; var m=b.length; var alice=0; var bob=0; var i; if(n=m){ for(i=0;i=1&a[i]<=100&b[i]>=1&b[i]<=100) { if(a[i]>b[i]){alice +=1; } if(a[i]

  3. A very big sum of array

    function aVeryBigSum(ar) { var n =ar.length; var x=0; var i; if(n>0&n<=10){ for(i=0;i=0&ar[i]<=10000000000) { x+=ar[i]; } } return x; } }

  4. timeConversion function

    function timeConversion(s) { /* * Write your code here. */ var x=s.split(":"); var y= x[2].slice(2,4); var result; if(y=="AM"){ if(x[0]==12){ result="00:"+x[1]+":"+x[2].slice(0,2); } else{ result=s.slice(0,8); } } if(y=="PM"){ if(x[0]==12){ result=s.slice(0,8); } else{ var z =parseInt(x[0])+12; result= z.toString()+":"+x[1]+":"+x[2].slice(0,2); } } return result; }

  5. diagonalDifference of metrix

    function diagonalDifference(arr) { // Write your code here var n = arr.length; var d1 = 0; var d2 = 0; for(var i=0; i

  6. Apple Orange problem

    function countApplesAndOranges(s, t, a, b, apples, oranges) { let appleCount = 0, orangeCount = 0, p1 = 0, p2 = 0; while (p1 < apples.length || p2 < oranges.length) { // apple count if (apples[p1] >= 0) { let appleVal = a + apples[p1]; if (appleVal >= s && appleVal <= t) { appleCount += 1 p1 += 1; } else { p1 += 1 } } else { p1 += 1; } // oranges count if (oranges[p2] < 0) { let orangeVal = b + oranges[p2]; if (orangeVal >= s && orangeVal <= t) { orangeCount += 1; p2 += 1; } else { p2 += 1; } } else { p2 += 1; } } console.log(appleCount); console.log(orangeCount); }

  7. staircase

    function staircase(n) { let output = ''; for (let i = 1; i <= n; i++) { for (let s = n - 1; s >= i; s--) { output += ' ' } for (let h = 1; h <= i; h++) { output += '#' } // new line output += "\n"; } console.log(output); }