Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @Date : 2018/05/25
- * @By : Erick Hermawan
- * @Email : erick.hermawan21@gmail.com
- */
- // Test No. 1
- console.log('============== Result No.1 : '+sumMinMax([1, 2, 3, 4, 5, 6]));
- function sumMinMax(listInteger){
- var listCalculated = [];
- var i = 1;
- var minValue = 0;
- var maxValue = 0;
- while (i <= 6) {
- listCalculated.push(calculate(i))
- i++;
- }
- return Math.min.apply(Math, listCalculated) + " " + Math.max.apply(Math, listCalculated) ;
- }
- function calculate(valueNotSum){
- var thisValue = 0;
- for (var i = 1; i <= 6; i++) {
- if(valueNotSum != i) thisValue = thisValue + i;
- }
- return thisValue;
- }
- // End Test No. 1
- // Test No. 2
- console.log('============== Result No.2 : '+printStair(6));
- function printStair(paramValue){
- var thisResult = "\n";
- if((paramValue >= 1) && (paramValue <= 60)){
- for (var i = 1; i <= paramValue; i++) {
- if(i % 3 != 0) {
- // Loop to add first space
- var firstSpace = paramValue - i;
- for (var x = 0; x < firstSpace; x++) {
- thisResult = thisResult + ' ';
- }
- // Loop to add multiple #
- for (var y = 0; y < i; y++) {
- thisResult = thisResult + '#';
- }
- // Add new line
- thisResult = thisResult + '\n';
- }else{
- // Loop to add first space
- var firstSpace = paramValue - i;
- for (var x = 0; x < firstSpace; x++) {
- thisResult = thisResult + ' ';
- }
- // Loop to add multiple =
- for (var y = 0; y < i; y++) {
- thisResult = thisResult + '=';
- }
- // Add new line
- thisResult = thisResult + '\n';
- }
- }
- return thisResult;
- }
- else return "Wrong value parameter";
- }
- // End Test No. 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement