mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix: salary tracker step 32 misleading hint (#67324)
This commit is contained in:
+10
-1
@@ -22,7 +22,16 @@ You should have a fourth `if` statement inside your `level` setter.
|
||||
Your `if` statement should use `hasattr(self, '_level')` to check if `_level` exists before comparing.
|
||||
|
||||
```js
|
||||
({ test: () => assert(runPython(`_Node(_code).find_class("Employee").find_functions("level")[1].find_ifs()[3].find_conditions()[0].is_equivalent("hasattr(self, '_level') and Employee._base_salaries[new_level] < Employee._base_salaries[self.level]")`)) })
|
||||
({ test: () => assert(runPython(`"hasattr(self, '_level')" in str(_Node(_code).find_class("Employee").find_functions("level")[1].find_ifs()[3].find_conditions()[0])`)) })
|
||||
```
|
||||
|
||||
Your `if` statement should compare `Employee._base_salaries[new_level]` against `Employee._base_salaries[self.level]` to check if the new level has a lower base salary.
|
||||
|
||||
```js
|
||||
({ test: () => assert(runPython(`
|
||||
cond = _Node(_code).find_class("Employee").find_functions("level")[1].find_ifs()[3].find_conditions()[0]
|
||||
cond.is_equivalent("hasattr(self, '_level') and Employee._base_salaries[new_level] < Employee._base_salaries[self.level]") or cond.is_equivalent("hasattr(self, '_level') and Employee._base_salaries[self.level] > Employee._base_salaries[new_level]")
|
||||
`)) })
|
||||
```
|
||||
|
||||
When `new_level` is lower than `self.level`, you should raise a `ValueError` with the message `Cannot change to lower level.`
|
||||
|
||||
Reference in New Issue
Block a user