Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sicpjs/1.1.6] Incorrect Solutions to Exercise 1.1 (const examples) #1072

Open
jdfm opened this issue Jan 2, 2025 · 1 comment
Open

[sicpjs/1.1.6] Incorrect Solutions to Exercise 1.1 (const examples) #1072

jdfm opened this issue Jan 2, 2025 · 1 comment
Labels

Comments

@jdfm
Copy link

jdfm commented Jan 2, 2025

Both when running the example code in the inline IDE and also in the browser's console, the following expressions result in undefined being printed:

// exercise 1.1.6
const a = 3; // prints undefined

// exercise 1.1.7
const b = a + 1; // prints undefined

In the solutions, the values listed are 3 and 4 respectively. Which, given the results above, is incorrect.

The expressions that do result in 3 and 4 would be:

a = 3; // prints 3
b = a + 1; // prints 4

See attached screenshots for proof.

inline IDE results

inline-ide--1 1 6 inline-ide--1 1 7

console results

console--1 1 6-1 1 7

console corrected results

console--corrected-1 1 6-1 1 7
@martin-henz martin-henz added the Bug label Jan 5, 2025
@martin-henz
Copy link
Member

Yes, the solution should indicate that these two cases

// exercise 1.1.6
const a = 3; // prints undefined

// exercise 1.1.7
const b = a + 1; // prints undefined

should print undefined. Constant declarations don't produce any value in JavaScript. Chapter 1 doesn't mention this, but the excercise solution would be an opportunity to point this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants