Freecodecamp: Operator chains

Created on 23 Mar 2016  路  5Comments  路  Source: freeCodeCamp/freeCodeCamp

Challenge Storing Values with the Equal Operator has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

// Setup
var a;
var b = 2;

// Only change code below this line

b = a = 7;

The parser doesn't accept chaining operators... ;)

bike shedding discussing

Most helpful comment

I think the instructions are pretty clear and unambiguous. They tell you exactly what to do and in what order to do it. The tests then test for that.

Yes, the chained answer is "correct" in the general sense, but it is not technically possible to test for all possible correct solutions - just the ones we're looking for.

These challenges are intended to serve people who are brand new to code. If you are experienced to know what chaining operators are, then why are you even doing these challenges to begin with? These challenges are optional.

All 5 comments

instructions are Assign the value 7 to variable a.
Assign the contents of a to variable b.
which is like var a = 7;
var b = a;
please use chat room https://gitter.im/FreeCodeCamp/FreeCodeCamp before posting here

@cannelflow: JavaScript evaluates assignment operators right to left, so b = a = 7 is equal to a = 7; b = a;

My answer stands correct.

It does seem to be a legitimate way to store a variable. What's your opinion @SaintPeter on changing the regex for this? I don't see any reason to not to add this case.

I think the instructions are pretty clear and unambiguous. They tell you exactly what to do and in what order to do it. The tests then test for that.

Yes, the chained answer is "correct" in the general sense, but it is not technically possible to test for all possible correct solutions - just the ones we're looking for.

These challenges are intended to serve people who are brand new to code. If you are experienced to know what chaining operators are, then why are you even doing these challenges to begin with? These challenges are optional.

I agree with @SaintPeter . This exercise is purely concentrating on the basics, and adding complex checks would be tedious to manage as well.

While I agree @adrenalin you may have got a valid assignment operation here, it just defeats the purpose of the challenge and its target audience.

Thanks, and happy Coding.

Was this page helpful?
0 / 5 - 0 ratings