From 6c750a796a06126291e63d0bd52267c1c3b69cd1 Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Sun, 1 Feb 2026 22:30:09 +0700 Subject: [PATCH 01/13] cobba commit, hanya mencoba --- Loop-Array/countingSheep.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Loop-Array/countingSheep.js b/Loop-Array/countingSheep.js index e0ee29a..2c21085 100644 --- a/Loop-Array/countingSheep.js +++ b/Loop-Array/countingSheep.js @@ -4,6 +4,7 @@ function countSheeps(sheep) { // TODO + let } console.log(countSheeps([])) //0 From 3d07af632893a61d1404a6907083f6b5b7875385 Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Sun, 1 Feb 2026 22:39:31 +0700 Subject: [PATCH 02/13] mencobaaaa --- Loop-Array/countingSheep.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Loop-Array/countingSheep.js b/Loop-Array/countingSheep.js index 2c21085..6ac6039 100644 --- a/Loop-Array/countingSheep.js +++ b/Loop-Array/countingSheep.js @@ -4,7 +4,7 @@ function countSheeps(sheep) { // TODO - let + let coba =0; } console.log(countSheeps([])) //0 From 15ba0b696d78d1c1c7cc7bc30208d95a4b935853 Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Sun, 1 Feb 2026 22:46:42 +0700 Subject: [PATCH 03/13] nyoba yang ke sekian --- Loop-Array/countingSheep.js | 2 +- Loop-Array/findHighest.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Loop-Array/countingSheep.js b/Loop-Array/countingSheep.js index 6ac6039..b766696 100644 --- a/Loop-Array/countingSheep.js +++ b/Loop-Array/countingSheep.js @@ -4,7 +4,7 @@ function countSheeps(sheep) { // TODO - let coba =0; + let cobaah =0; } console.log(countSheeps([])) //0 diff --git a/Loop-Array/findHighest.js b/Loop-Array/findHighest.js index ffb59a5..7566e93 100644 --- a/Loop-Array/findHighest.js +++ b/Loop-Array/findHighest.js @@ -4,6 +4,7 @@ function findHighestInt(arr) { //your code here + let halo = 0; } From 786dccec9b20f54b36e8946750a75c79df0d6d3e Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Mon, 2 Feb 2026 21:34:54 +0700 Subject: [PATCH 04/13] push soal counting sheep --- Loop-Array/countingSheep.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Loop-Array/countingSheep.js b/Loop-Array/countingSheep.js index b766696..9ce52b7 100644 --- a/Loop-Array/countingSheep.js +++ b/Loop-Array/countingSheep.js @@ -4,9 +4,19 @@ function countSheeps(sheep) { // TODO - let cobaah =0; + let benar = 0; + + //looping + for(let i=0; i < sheep.length; i++ ){ + if(sheep[i] == true){ + benar++; + } + } + return benar; } + + console.log(countSheeps([])) //0 console.log(countSheeps([undefined])) //0 console.log(countSheeps([null])) //0 @@ -18,5 +28,4 @@ console.log(countSheeps( true,false,true,false, true,false,false,true, true,true,true,true, - false,false,true,true -])) //17 \ No newline at end of file + false,false,true,true])) //17 \ No newline at end of file From 5422b7c84b587261331e888b37133af9eedd325b Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Mon, 2 Feb 2026 21:42:53 +0700 Subject: [PATCH 05/13] nge push soal findHighest --- Loop-Array/findHighest.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Loop-Array/findHighest.js b/Loop-Array/findHighest.js index 7566e93..73b68a8 100644 --- a/Loop-Array/findHighest.js +++ b/Loop-Array/findHighest.js @@ -4,7 +4,15 @@ function findHighestInt(arr) { //your code here - let halo = 0; + let high = 0; + + //Loop + for(let i = 0; i <= arr.length; i++){ + if(arr[i] > high){ + high = arr[i]; + } + } + return high; } From 227d54d5c7159b31bf6af86140ed4b37defa8f01 Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Mon, 2 Feb 2026 21:48:50 +0700 Subject: [PATCH 06/13] ngepush soal findneedle --- Loop-Array/findNeedle.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Loop-Array/findNeedle.js b/Loop-Array/findNeedle.js index d4c9660..7d5b6f5 100644 --- a/Loop-Array/findNeedle.js +++ b/Loop-Array/findNeedle.js @@ -4,6 +4,12 @@ function findNeedle(haystack) { // your code here + for (let i = 0; i <= haystack.length; i++){ + if (haystack[i] === "needle"){ + return `found the needle at position ${i}` + } + } + } let haystack_1 = ['3', '123124234', undefined, 'needle', 'world', 'hay', 2, '3', true, false]; From 0f45fcc9cb05c94e26caf2835474060fca9258bb Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Mon, 2 Feb 2026 21:53:15 +0700 Subject: [PATCH 07/13] ngepush soal findSmallest --- Loop-Array/findSmallest.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Loop-Array/findSmallest.js b/Loop-Array/findSmallest.js index ad42028..e58733c 100644 --- a/Loop-Array/findSmallest.js +++ b/Loop-Array/findSmallest.js @@ -4,7 +4,15 @@ function findSmallestInt(arr) { //your code here - + let kecil = 500; + + // Loop + for(let i = 0; i <= arr.length; i++){ + if(arr[i] < kecil){ + kecil = arr[i]; + } + } + return kecil; } console.log(findSmallestInt([78,56,232,12,8])); //8 From 064f32e7fe850ccd38fbc0425b5b8180c4af6669 Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Mon, 2 Feb 2026 21:58:41 +0700 Subject: [PATCH 08/13] push soal positif sum --- Loop-Array/positifSum.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Loop-Array/positifSum.js b/Loop-Array/positifSum.js index 6483e00..3ea11d2 100644 --- a/Loop-Array/positifSum.js +++ b/Loop-Array/positifSum.js @@ -4,6 +4,15 @@ function positiveSum(arr) { //code here + let cum = 0; + + //Looping + for(let i = 0; i <= arr.length; i++){ + if(arr[i] > 0){ + cum = cum + arr[i]; + } + } + return cum; } console.log(positiveSum([1,2,3,4,5])) //15 From 5b8798f55c95a2ffa5599eadbfb23212c6a83912 Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Mon, 2 Feb 2026 23:28:13 +0700 Subject: [PATCH 09/13] push soal squareSum --- Loop-Array/squareSum.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Loop-Array/squareSum.js b/Loop-Array/squareSum.js index 9d07259..c750fa1 100644 --- a/Loop-Array/squareSum.js +++ b/Loop-Array/squareSum.js @@ -4,6 +4,12 @@ function squareSum(numbers){ //code here + let hasil = 0; + for(let i = 0; i < numbers.length; i++){ + let angka = numbers[i] **2; + hasil = hasil + angka; + } + return hasil; } console.log(squareSum([1,2])); //5 From c8e3c003549a03b1729e9ce6cffa8c961c5ae2de Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Mon, 2 Feb 2026 23:41:04 +0700 Subject: [PATCH 10/13] push soal centuryYear --- Loop-Number/centuryYear.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Loop-Number/centuryYear.js b/Loop-Number/centuryYear.js index 296af71..8e16615 100644 --- a/Loop-Number/centuryYear.js +++ b/Loop-Number/centuryYear.js @@ -6,7 +6,12 @@ function century(year) { // Finish this :) - return; + let abad = 1; + while (year > 100){ + year = year - 100; + abad = abad + 1; + } + return abad; } console.log(century(1705)); //18 From c63dc9277d43b5ccaed4cb79cb4d16bdb2bd367e Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Mon, 2 Feb 2026 23:47:16 +0700 Subject: [PATCH 11/13] push soal summation --- Loop-Number/summation.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Loop-Number/summation.js b/Loop-Number/summation.js index 327ab74..d33d200 100644 --- a/Loop-Number/summation.js +++ b/Loop-Number/summation.js @@ -5,6 +5,11 @@ function summation (num) { // Code here + let angka = 0; + for(let i = 1; i <= num; i++){ + angka = angka + i; + } + return angka; } console.log(summation(1)); //1 From 909682ecc3f81363901eb08b179aed693cb0e7f0 Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Thu, 5 Feb 2026 21:47:59 +0700 Subject: [PATCH 12/13] push soal LOOP STRING --- Loop-String/abbrevName.js | 6 ++++++ Loop-String/noSpace.js | 6 ++++++ Loop-String/removeChar.js | 10 ++++++++-- Loop-String/stringRepeat.js | 5 +++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Loop-String/abbrevName.js b/Loop-String/abbrevName.js index 48124c2..3627d7a 100644 --- a/Loop-String/abbrevName.js +++ b/Loop-String/abbrevName.js @@ -5,6 +5,12 @@ function abbrevName(name){ //code here + let hasil = ""; + for(let i = 0; i <= name.length; i++){ + if(name[i] >= 'A' && name[i] <= 'Z') hasil += name[i]; + if(name[i] === " ") hasil += "."; + } + return hasil; } console.log(abbrevName("Sam Harris")); //S.H diff --git a/Loop-String/noSpace.js b/Loop-String/noSpace.js index e62ba23..6cc38bf 100644 --- a/Loop-String/noSpace.js +++ b/Loop-String/noSpace.js @@ -4,6 +4,12 @@ function noSpace(x){ //code here + let hasil = ""; + + for(let i = 0; i <= x.length; i++){ + if(x[i] !==" ") hasil += x[i]; + } + return hasil } diff --git a/Loop-String/removeChar.js b/Loop-String/removeChar.js index 2c09bed..a86a016 100644 --- a/Loop-String/removeChar.js +++ b/Loop-String/removeChar.js @@ -3,8 +3,14 @@ //source: https://www.codewars.com/kata/56bc28ad5bdaeb48760009b0 function removeChar(str){ - -}; + let hasil = ""; + for(let i = 0; i <= str.length; i++){ + if(i > 0 && i < str.length-1){ + hasil += str[i]; + } + } + return hasil; +} console.log(removeChar('eloquent')); //loquen console.log(removeChar('country')); //ountr diff --git a/Loop-String/stringRepeat.js b/Loop-String/stringRepeat.js index ca7175f..5b502db 100644 --- a/Loop-String/stringRepeat.js +++ b/Loop-String/stringRepeat.js @@ -4,6 +4,11 @@ function repeatStr (n, s) { //code here + let hasil = ""; + for(let i = 0; i < n; i++){ + hasil = hasil + n; + } + return hasil; } console.log(repeatStr(3, "*")); //*** From 61a9848d3157614ac91bf063afb3b66856eeb1ff Mon Sep 17 00:00:00 2001 From: irhamchandra99-crypto Date: Thu, 5 Feb 2026 23:20:38 +0700 Subject: [PATCH 13/13] Push soal PATTERN-PRINTING --- Pattern-Printing/diamond.js | 32 +++++++++++++++++++++++- Pattern-Printing/papanCatur.js | 10 ++++++++ Pattern-Printing/patternX.js | 10 ++++++++ Pattern-Printing/persegi.js | 6 +++++ Pattern-Printing/persegiBolong.js | 10 ++++++++ Pattern-Printing/piramid.js | 11 ++++++++ Pattern-Printing/piramid2.js | 10 ++++++++ Pattern-Printing/piramidTerbalik.js | 14 ++++++++++- Pattern-Printing/segitigaSiku.js | 6 +++++ Pattern-Printing/segitigaSikuTerbalik.js | 7 ++++++ 10 files changed, 114 insertions(+), 2 deletions(-) diff --git a/Pattern-Printing/diamond.js b/Pattern-Printing/diamond.js index a813fb7..e63f80d 100644 --- a/Pattern-Printing/diamond.js +++ b/Pattern-Printing/diamond.js @@ -1,6 +1,36 @@ function berlian(num) { - let pattern = ''; + // code here + let pattern = ""; + + //loop segitiga atas + for(let i = 0; i < num; i++){ + //Loop Spasi + for(let j = 0; j < num - i - 1; j++){ + pattern += " "; + } + // Loop Bintang + for(let k = 0; k < 2 * i + 1; k++){ + pattern += "*"; + } + pattern += `\n`; + } + //Loop Bawah + for (let i = num - 2; i >= 0; i--) { + + // spasi + for (let j = 0; j < num - i - 1; j++) { + pattern += ' '; + } + + // bintang + for (let k = 0; k < 2 * i + 1; k++) { + pattern += '*'; + } + + + pattern += '\n'; + } return pattern; } diff --git a/Pattern-Printing/papanCatur.js b/Pattern-Printing/papanCatur.js index c90644e..eaa81a8 100644 --- a/Pattern-Printing/papanCatur.js +++ b/Pattern-Printing/papanCatur.js @@ -4,6 +4,16 @@ function papanCatur(num) { let pattern = ''; // code here + for(let i = 0; i < num; i++){ + for(let j = 0; j < num; j++){ + if((i+j) % 2 == 0){ + pattern += `#`; + }else{ + pattern += ` `; + } + } + pattern += '\n'; + } return pattern; } diff --git a/Pattern-Printing/patternX.js b/Pattern-Printing/patternX.js index b191574..6f8e0bb 100644 --- a/Pattern-Printing/patternX.js +++ b/Pattern-Printing/patternX.js @@ -5,6 +5,16 @@ function polaX(num) { let pattern = ''; // code here + for(let i = 0; i < num; i++){ + for(let j = 0; j < num; j++){ + if((i === j) || (i + j === num - 1)){ + pattern += '*'; + }else{ + pattern += ' '; + } + } + pattern += '\n'; + } return pattern; } diff --git a/Pattern-Printing/persegi.js b/Pattern-Printing/persegi.js index 1c28f6d..728ffd8 100644 --- a/Pattern-Printing/persegi.js +++ b/Pattern-Printing/persegi.js @@ -2,6 +2,12 @@ function persegi(num) { let pattern = ''; // code here + for(let i = 0 ; i < num; i++){ + for(let j = 0; j < num; j++){ + pattern += '*'; + } + pattern += '\n'; + } return pattern; } diff --git a/Pattern-Printing/persegiBolong.js b/Pattern-Printing/persegiBolong.js index 398fc02..fe3a9c4 100644 --- a/Pattern-Printing/persegiBolong.js +++ b/Pattern-Printing/persegiBolong.js @@ -2,6 +2,16 @@ function persegiBolong(num) { let pattern = ''; // code here + for(let i = 0; i < num; i++){ + for(let j = 0; j < num; j++){ + if(i == 0 || i == num -1 || j == 0 || j == num-1){ + pattern += '*'; + }else{ + pattern += ' '; + } + } + pattern += '\n'; + } return pattern; } diff --git a/Pattern-Printing/piramid.js b/Pattern-Printing/piramid.js index afa2b5d..33ef347 100644 --- a/Pattern-Printing/piramid.js +++ b/Pattern-Printing/piramid.js @@ -3,9 +3,20 @@ function piramida(num) { let pattern = ''; // code here + for(let i = 0; i < num ; i++){ + for(let j = 0; j < num - i - 1; j++){ + pattern += ' '; + } + for (let k = 0; k < 2 * i + 1; k++) { + pattern += '*'; + } + + pattern += '\n'; + } return pattern; } + // use case console.log(piramida(5)); /* diff --git a/Pattern-Printing/piramid2.js b/Pattern-Printing/piramid2.js index 14e316d..2ab2fe5 100644 --- a/Pattern-Printing/piramid2.js +++ b/Pattern-Printing/piramid2.js @@ -3,6 +3,16 @@ function piramida2(num) { let pattern = ''; // code here + for(let i = 0; i < num ; i++){ + for(let j = 0; j < num - i - 1; j++){ + pattern += ' '; + } + for (let k = 0; k < i ; k++) { + pattern += '* '; + } + pattern += '*'; + pattern += '\n'; + } return pattern; } diff --git a/Pattern-Printing/piramidTerbalik.js b/Pattern-Printing/piramidTerbalik.js index 8c5677e..ca1a9f8 100644 --- a/Pattern-Printing/piramidTerbalik.js +++ b/Pattern-Printing/piramidTerbalik.js @@ -1,6 +1,18 @@ function piramidaTerbalik(num) { let pattern = ''; // code here + for(let i = 0; i < num ; i++){ + + for(let j = 0; j < i; j++){ + pattern += ' '; + } + + for (let k = 0; k < 2 * (num - i) - 1; k++) { + pattern += '*'; + } + + pattern += '\n'; + } return pattern; } @@ -9,7 +21,7 @@ console.log(piramidaTerbalik(5)); /* expected result ********* - ******* + ******* ***** *** * diff --git a/Pattern-Printing/segitigaSiku.js b/Pattern-Printing/segitigaSiku.js index c5cce1e..4ffc505 100644 --- a/Pattern-Printing/segitigaSiku.js +++ b/Pattern-Printing/segitigaSiku.js @@ -2,6 +2,12 @@ function segitigaSiku(num) { let pattern = ''; // code here + for(let i = 0; i <= num; i++){ + for(let j = 0; j < i; j++){ + pattern += '*'; + } + pattern += '\n'; + } return pattern; } diff --git a/Pattern-Printing/segitigaSikuTerbalik.js b/Pattern-Printing/segitigaSikuTerbalik.js index 287c2dd..f4005e6 100644 --- a/Pattern-Printing/segitigaSikuTerbalik.js +++ b/Pattern-Printing/segitigaSikuTerbalik.js @@ -2,6 +2,13 @@ function segitigaTerbalik(num) { let pattern = ''; // code here + for(let i = 0; i < num ; i++){ + for (let k = 0; k < num - i ; k++) { + pattern += '*'; + } + + pattern += '\n'; + } return pattern; }