Skip to content

Evaluate function fails if node.value is falsy #7

@jasonsbarr

Description

@jasonsbarr

Using 0 in a function, e.g. max, evaluates to NaN. Entering 0 in the REPL as a value expression evaluates to undefined. Empty string also evaluates to undefined.

I fixed it in my local copy by simply adding checks for 0 and an empty string to the evaluate function:

if (node.value) {
  return node.value;
} else if (node.value === 0) {
  return 0;
} else if (node.value === '') {
  return '""';
}

I guess I could submit a pull request, but I really just wanted to make sure you were aware in case you decided to redo this workshop or put it on somewhere else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions