This repository has been archived by the owner on Jan 2, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added questions on even, findTheNeedle functionality and test
- Loading branch information
NawalC
committed
Apr 6, 2018
1 parent
7dfd815
commit 71fef91
Showing
2 changed files
with
40 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nawal, this is the only function I'm not wholly comfortable with. Whilst it works OK and passes the test, it's heavily dependent on being passed an object that only contains Fords, Land Rovers, Toyotas, or Hondas. If it were to be passed a different brand e.g. BMW, or GMC, it would add the sales of those brands up.
It's quite an important feature of coding that you avoid hard coding values as far as possible, as it makes maintenance much harder were the function to be used with different values in the future.
Here's a different version of the function that works regardless of the brands contained in the object passed into it. Have a look through it and see whether you understand how it works. I'd be more than happy to talk you through any parts you're not clear on tomorrow.