Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. ZADANIE 1 ////////////////////////////////////
  2. var calculator =
  3. {
  4. save: function(newN)
  5. {
  6. this.n = newN;
  7.  
  8. },
  9. sqrt: function()
  10. {
  11. return Math.sqrt(this.n);
  12. },
  13.  
  14. };
  15.  
  16. calculator.save(25);
  17. console.log( calculator.sqrt() );
  18.  
  19.  
  20. ZADANIE 3 /////////////////////////////////////////
  21.  
  22.  
  23.  
  24.  
  25. function biggestSumOfTwoElements(arr) {
  26.  
  27. if(arr.length === 0){
  28. return "pusta tablica"
  29. }else if (arr.length === 1){
  30. return arr[0]
  31. }
  32.  
  33. let result = 0;
  34. result+=Math.max(...arr);
  35. arr.splice(arr.indexOf(Math.max(...arr)));
  36. result+=Math.max(...arr);
  37. return result
  38.  
  39. }
  40. console.log(biggestSumOfTwoElements([1,2,3,4]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement