From 9600a1501a66683a47ce1a3dca80bc8473a90959 Mon Sep 17 00:00:00 2001 From: koronya Date: Mon, 13 Apr 2026 03:47:08 +0900 Subject: [PATCH] [JS][7kyu] Sum of a Beach --- codewars/7kyu/sum-of-a-beach/koronya.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 codewars/7kyu/sum-of-a-beach/koronya.js diff --git a/codewars/7kyu/sum-of-a-beach/koronya.js b/codewars/7kyu/sum-of-a-beach/koronya.js new file mode 100644 index 000000000..a53bd2ea9 --- /dev/null +++ b/codewars/7kyu/sum-of-a-beach/koronya.js @@ -0,0 +1,15 @@ +// [JS][7kyu] Sum of a Beach +// sum-of-a-beach +// https://www.codewars.com/kata/5b37a50642b27ebf2e000010/train/javascript + +const sumOfABeach = (beach) => { + const lowerBeach = beach.toLowerCase() + const pattern = /sand|water|fish|sun/g + const result = lowerBeach.match(pattern) + return result ? result.length : 0 +} + +sumOfABeach('WAtErSlIde') === 1 +sumOfABeach('GolDeNSanDyWateRyBeaChSuNN') === 3 +sumOfABeach('gOfIshsunesunFiSh') === 4 +sumOfABeach('cItYTowNcARShoW') === 0