diff --git a/frontend/src/ts/test/funbox/funbox-functions.ts b/frontend/src/ts/test/funbox/funbox-functions.ts index 4810b36fbc74..200720604cc0 100644 --- a/frontend/src/ts/test/funbox/funbox-functions.ts +++ b/frontend/src/ts/test/funbox/funbox-functions.ts @@ -318,18 +318,32 @@ const list: Partial> = { }, rAnDoMcAsE: { alterText(word: string): string { - let randomcaseword = word[0] as string; - for (let i = 1; i < word.length; i++) { - if ( - randomcaseword[i - 1] === - (randomcaseword[i - 1] as string).toUpperCase() - ) { - randomcaseword += (word[i] as string).toLowerCase(); + let randomCaseWord = ""; + + for (let letter of word) { + if (Math.random() < 0.5) { + randomCaseWord += letter.toUpperCase(); } else { - randomcaseword += (word[i] as string).toUpperCase(); + randomCaseWord += letter.toLowerCase(); } } - return randomcaseword; + + return randomCaseWord; + }, + }, + sPoNgEcAsE: { + alterText(word: string): string { + let spongeCaseWord = ""; + + for (let i = 0; i < word.length; i++) { + if (i % 2 === 0) { + spongeCaseWord += word[i]?.toLowerCase(); + } else { + spongeCaseWord += word[i]?.toUpperCase(); + } + } + + return spongeCaseWord; }, }, rot13: { diff --git a/frontend/static/challenges/_list.json b/frontend/static/challenges/_list.json index 73564f3036f9..69d487158ea0 100644 --- a/frontend/static/challenges/_list.json +++ b/frontend/static/challenges/_list.json @@ -613,11 +613,11 @@ } }, { - "name": "iKiNdAlIkEhOwInEfFiCiEnTqWeRtYiS", - "display": "I kInDa LiKe HoW iNeFfIcIeNt QwErTy Is", + "name": "iKINdaLikEHoWinEFFICIeNtQwErtYIs.", + "display": "i KINda LikE HoW inEFFICIeNt QwErtY Is.", "autoRole": true, "type": "funbox", - "parameters": [["rAnDoMcAsE"], "time", 3600], + "parameters": [["sPoNgEcAsE"], "time", 3600], "requirements": { "wpm": { "min": 100 @@ -626,7 +626,7 @@ "min": 60 }, "funbox": { - "exact": ["rAnDoMcAsE"] + "exact": ["sPoNgEcAsE"] } } }, diff --git a/packages/funbox/src/list.ts b/packages/funbox/src/list.ts index bae05e7f6f77..f43ab93e8c80 100644 --- a/packages/funbox/src/list.ts +++ b/packages/funbox/src/list.ts @@ -114,13 +114,21 @@ const list: Record = { name: "arrows", }, rAnDoMcAsE: { - description: "I kInDa LiKe HoW iNeFfIcIeNt QwErTy Is.", + description: "raNdomIze ThE CApitaLizatIon Of EveRY LeTtEr.", canGetPb: false, difficultyLevel: 2, properties: ["changesCapitalisation"], frontendFunctions: ["alterText"], name: "rAnDoMcAsE", }, + sPoNgEcAsE: { + description: "I kInDa LiKe HoW iNeFfIcIeNt QwErTy Is.", + canGetPb: false, + difficultyLevel: 2, + properties: ["changesCapitalisation"], + frontendFunctions: ["alterText"], + name: "sPoNgEcAsE", + }, capitals: { description: "Capitalize Every Word.", canGetPb: false, diff --git a/packages/schemas/src/configs.ts b/packages/schemas/src/configs.ts index edfd6af29355..8cb6325887cc 100644 --- a/packages/schemas/src/configs.ts +++ b/packages/schemas/src/configs.ts @@ -279,6 +279,7 @@ export const FunboxNameSchema = z.enum([ "choo_choo", "arrows", "rAnDoMcAsE", + "sPoNgEcAsE", "capitals", "layout_mirror", "layoutfluid",