From 3853a1ea262889d76517bf052d77a55cb3da334e Mon Sep 17 00:00:00 2001 From: Sola-Ade Date: Mon, 10 Jun 2024 16:29:33 +0100 Subject: [PATCH 1/3] First trial of correction. --- src/count-occurrences.js | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/count-occurrences.js b/src/count-occurrences.js index da056be..5965c9c 100644 --- a/src/count-occurrences.js +++ b/src/count-occurrences.js @@ -9,24 +9,10 @@ * @param {string} n - string to count occurrences off * @returns {number} how many occurrences of the string are in the array */ -function x -( -y, -n -) - - - { - let x2=( -( -( - ( -(0) -))) - ) - for ( - - let mars of ( +function x(y,n){ + let x2 = (0) +} + for(let mars of ( (( y)))){if(((((n=mars))))){x2++}}return(((((x2)))))} From 1153536f422366d420e605fe55619b03d57fc279 Mon Sep 17 00:00:00 2001 From: Sola-Ade Date: Mon, 10 Jun 2024 16:33:51 +0100 Subject: [PATCH 2/3] More changes made. --- src/count-occurrences.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/count-occurrences.js b/src/count-occurrences.js index 5965c9c..139786d 100644 --- a/src/count-occurrences.js +++ b/src/count-occurrences.js @@ -12,9 +12,10 @@ function x(y,n){ let x2 = (0) } - for(let mars of ( - (( - y)))){if(((((n=mars))))){x2++}}return(((((x2)))))} + for(let mars of y){ + if(n=mars){x2++}} + return x2 + } console.log(x(["na", "na", "na", "na", "BATMAN"], "na"), 4); console.log(x(["na", "na", "na", "na", "BATMAN"], "BATMAN"), 1); From 7df0c1493e823a8ca7b89fbad463099e6694240f Mon Sep 17 00:00:00 2001 From: Sola-Ade Date: Mon, 10 Jun 2024 16:36:02 +0100 Subject: [PATCH 3/3] More changes. --- src/count-occurrences.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/count-occurrences.js b/src/count-occurrences.js index 139786d..ae7af58 100644 --- a/src/count-occurrences.js +++ b/src/count-occurrences.js @@ -15,7 +15,7 @@ function x(y,n){ for(let mars of y){ if(n=mars){x2++}} return x2 - } + console.log(x(["na", "na", "na", "na", "BATMAN"], "na"), 4); console.log(x(["na", "na", "na", "na", "BATMAN"], "BATMAN"), 1);