Skip to content

Instantly share code, notes, and snippets.

View JidLaurence's full-sized avatar
🏠
Working from home

Jed Laurence Udtohan JidLaurence

🏠
Working from home
View GitHub Profile
function summarizeNumber() {
let i = 0;
let total = 0;
while (i < arguments.length) {
total += arguments[i];
i++;
}
return total;
SELECT
c.CampaignName,
COUNT(DISTINCT r.RoundID) AS RoundsCount,
COUNT(s.SegmentID) AS SegmentsCount
FROM
Campaigns c
LEFT JOIN
Rounds r ON c.CampaignID = r.CampaignID
LEFT JOIN
Segments s ON r.RoundID = s.RoundID
function countCharacterOccurrences({S, N, C}) {
// Total the number of times S should repeated to get variable N
// Calculate the number times of variable S should be repeated to reach the value of N
const totalRepeted = Math.ceil(N / S.length);
// Repeat the variable S to reach the desired length
const repeatedString = S.repeat(totalRepeted);
// Count occurrences of the variable C in the repeated string
return [...repeatedString].filter(char => char === C).length;
}