Skip to content

Uncaught SyntaxError ":" in recursive function signature #54189

@peternroth

Description

@peternroth

Uncaught SyntaxError C:\Users\Owner\Documents\TS\HelloWorlds\HelloHanoi\hanoi.ts:19
height: number,
^

function moveTower(
height: number,
fromPole: string,
toPole: string,
withPole: string
): void {
if (height >= 1) {
// Move tower of height-1 to an intermediate pole, using the destination pole.
moveTower(height - 1, fromPole, withPole, toPole);

// Move the remaining disk to the destination pole.
console.log(`Move disk from ${fromPole} to ${toPole}`);

// Move the tower of height-1 from the intermediate pole to the destination pole using the source pole.
moveTower(height - 1, withPole, toPole, fromPole);

}
}

// Call the function with the initial parameters.
moveTower(3, "A", "C", "B");

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions