Skip to content

Building a Spreadsheet: Logic for avoiding self-reference in function calls is broken #55060

@lasjorg

Description

@lasjorg

Describe the Issue

In step 31 we are asked to add a check that the value doesn't contain the id. As far as I can tell, this is to avoid a function call containing its own cell value.

However, the ids are uppercase, and the check is not converting the value.

A1 = 10
A2 = 10
A3 = =sum(a1, a2) -> 20
A1 = 10
A2 = 10
A3 = =sum(a1, a3) -> undefined (and Potential infinite loop in console)

But if you toUpperCase the value, that doesn’t happen.

Edit: As also pointed out in the thread, includes will match on partial strings. Causing a false positive with the value converted.

!"A11".includes("A1")

A1 = =sum(a2, a11)
A2 = 10
A11 = 10

Affected Page

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-functional-programming-by-building-a-spreadsheet/step-31

Your code




Expected behavior

Calling one of the functions with its own cell reference passed in as an argument should not run.

Screenshots

No response

System

  • Device: [e.g. iPhone 6, Laptop]
  • OS: [e.g. iOS 14, Windows 10, Ubuntu 20.04]
  • Browser: [e.g. Chrome, Safari]
  • Version: [e.g. 22]

Additional context

https://forum.freecodecamp.org/t/learn-functional-programming-by-building-a-spreadsheet-step-31/693224

Metadata

Metadata

Assignees

No one assigned

    Labels

    archived courseworkthe scope is archived coursework, it's lower priority than current curriculumscope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.status: discussingUnder discussion threads. Closed as stale after 60 days of inactivity.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions