Advertisement
erick21

Erick - Test at AskFast Rithm

May 25th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. /**
  2. * @Date : 2018/05/25
  3. * @By : Erick Hermawan
  4. * @Email : erick.hermawan21@gmail.com
  5. */
  6. // Test No. 1
  7. console.log('============== Result No.1 : '+sumMinMax([1, 2, 3, 4, 5, 6]));
  8. function sumMinMax(listInteger){
  9. var listCalculated = [];
  10. var i = 1;
  11. var minValue = 0;
  12. var maxValue = 0;
  13. while (i <= 6) {
  14. listCalculated.push(calculate(i))
  15. i++;
  16. }
  17. return Math.min.apply(Math, listCalculated) + " " + Math.max.apply(Math, listCalculated) ;
  18. }
  19.  
  20. function calculate(valueNotSum){
  21. var thisValue = 0;
  22. for (var i = 1; i <= 6; i++) {
  23. if(valueNotSum != i) thisValue = thisValue + i;
  24. }
  25. return thisValue;
  26. }
  27. // End Test No. 1
  28.  
  29. // Test No. 2
  30. console.log('============== Result No.2 : '+printStair(6));
  31. function printStair(paramValue){
  32.  
  33. var thisResult = "\n";
  34. if((paramValue >= 1) && (paramValue <= 60)){
  35. for (var i = 1; i <= paramValue; i++) {
  36. if(i % 3 != 0) {
  37.  
  38. // Loop to add first space
  39. var firstSpace = paramValue - i;
  40. for (var x = 0; x < firstSpace; x++) {
  41. thisResult = thisResult + ' ';
  42. }
  43.  
  44. // Loop to add multiple #
  45. for (var y = 0; y < i; y++) {
  46. thisResult = thisResult + '#';
  47. }
  48.  
  49. // Add new line
  50. thisResult = thisResult + '\n';
  51. }else{
  52.  
  53. // Loop to add first space
  54. var firstSpace = paramValue - i;
  55. for (var x = 0; x < firstSpace; x++) {
  56. thisResult = thisResult + ' ';
  57. }
  58.  
  59. // Loop to add multiple =
  60. for (var y = 0; y < i; y++) {
  61. thisResult = thisResult + '=';
  62. }
  63.  
  64. // Add new line
  65. thisResult = thisResult + '\n';
  66. }
  67. }
  68. return thisResult;
  69. }
  70. else return "Wrong value parameter";
  71. }
  72. // End Test No. 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement