Skip to content

Function Basics: Simplify function usage in initial example to avoid cognitive overload #29848

@joe-tecconsulting

Description

@joe-tecconsulting

Checks

Describe your suggestion

In the lesson introducing functions and how they are called, the first example is:

function favoriteAnimal(animal) {
    return animal + " is my favorite animal!";
}

console.log(favoriteAnimal('Goat'));

While this is technically correct, I think this example introduces too many concepts at once for learners who are just encountering functions. Specifically:

It uses a function inside another function call (console.log()), which adds a layer of abstraction.

The explanation talks about

passing a function call as an argument in a different function call

– a phrasing that may be conceptually heavy for beginners.

Suggestion:

Instead, consider introducing function calls in isolation first. For example:

function favoriteAnimal(animal) {
    return animal + " is my favorite animal!";
}

let message = favoriteAnimal('Goat');
console.log(message);

This keeps the focus squarely on:

  • How a function is called.
  • What it returns.
  • How we can use that return value (via assignment).

Then, once the learner understands the basics of return values and variables, it’s a good time to introduce using a function call as an argument.

Path

Foundations

Lesson Url

https://www.theodinproject.com/lessons/foundations-function-basics

(Optional) Discord Name

ralphwiggum69

(Optional) Additional Comments

No response

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions