marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
3.01k stars 793 forks source link

Project: A Programming language #469

Closed hkiame closed 5 years ago

hkiame commented 5 years ago

testing the run function it was concatenating instead of doing math.In the evaluate function where the expr.type is a value I had to add an if else statement to check if the value is a number then typecast it to a number.

if(/\d+/.test(expr.value)){ return Number(expr.value); }

marijnh commented 5 years ago

parseExpression already converts the value property of number expressions to number, so I don't think we need to do that again when evaluating. Can you provide an example of a call to run that doesn't work as expected?

hkiame commented 5 years ago

So sorry.. i missed that when i was writing the parseExpression. Thanks for the correction.