Skip to content

#155 Stuttering Function

Adam Kubiś edited this page Oct 28, 2026 · 1 revision

155 Stuttering Function

Write a function that stutters a word as if someone is struggling to read it.

The first two letters are repeated twice with an ellipsis ...

and space after each, and then the word is pronounced with a question mark?.

Current source and tests | Catalog | Testing and tooling

Run this solution

From the cloned repository root, after installing dependencies:

node "Edabit/155 Stuttering Function.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.

Current implementation and tests

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.

//Write a function that stutters a word as if someone is struggling to read it.
//The first two letters are repeated twice with an ellipsis ...
//and space after each, and then the word is pronounced with a question mark?.
function stutter(word) {
    return `${word.slice(0, 2)}... ${word.slice(0, 2)}... ${word}?`;
}
import { assertEquals } from '../testHelper.js';
assertEquals(stutter("incredible"), "in... in... incredible?")
assertEquals(stutter("am"), "am... am... am?")
assertEquals(stutter("outstanding"), "ou... ou... outstanding?")

Clone this wiki locally