Repository navigation
#154 Reverse Psychology
Adam Kubiś edited this page Oct 28, 2026
·
1 revision
For this challenge, you will NOT be given a string.
Your task isn't to add "Do not" before the given string.
If there is no given string, you will not return "Do not do anything."
Current source and tests | Catalog | Testing and tooling
From the cloned repository root, after installing dependencies:
node "Edabit/154 Reverse Psychology.js"Assertions are kept alongside the implementation and throw on failure. A successful run exits with code 0. Run every exercise with npm test or both lint and tests with npm run check.
This is the complete executable file, including its imports and inline test cases. Run it from the repository, not as an isolated file copied out of the wiki. Line endings and trailing whitespace are normalized; executable tokens are unchanged.
//For this challenge, you will NOT be given a string.
//Your task isn't to add "Do not" before the given string.
//If there is no given string, you will not return "Do not do anything."
function reversePsychology(s) {
return s ? `Do not ${s}.` : "Do not do anything.";
}
import { assertEquals } from '../testHelper.js';
assertEquals(reversePsychology("wash the dishes"), "Do not wash the dishes.")
assertEquals(reversePsychology("eat your lunch"), "Do not eat your lunch.")
assertEquals(reversePsychology("go to school"), "Do not go to school.")
assertEquals(reversePsychology(), "Do not do anything.")
assertEquals(reversePsychology("read"), "Do not read.")
assertEquals(reversePsychology("learn Python"), "Do not learn Python.")
assertEquals(reversePsychology("exercise"), "Do not exercise.")
assertEquals(reversePsychology("buy PC parts"), "Do not buy PC parts.")
assertEquals(reversePsychology("do your homework"), "Do not do your homework.")
assertEquals(reversePsychology("drink water"), "Do not drink water.")
assertEquals(reversePsychology("look around"), "Do not look around.")