This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function summarizeNumber() { | |
let i = 0; | |
let total = 0; | |
while (i < arguments.length) { | |
total += arguments[i]; | |
i++; | |
} | |
return total; |