Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialZeljko Porobija
11,491 PointsMy console shows no errors
Although I put "one" and "doz" as it had been done in the video, no errors were showed in the console. Did I do something wrong or it's just the console? Here's my code:
2 Answers
Simon Coates
28,694 PointsI'm not entirely sure what you're trying to do and haven't seen the video, but at a glance your conditions are wrong. if you want a float, you probably want your error condition to be ($amount == null || !is_float($amount)). The measure condition also needs to be inverted, i think. ($measure == null || !in_array(strtolower($measure), $this->measurements))
Simon Coates
28,694 Pointsif you want a little more variety in terms of what your type can be, you might want to us is_numeric. (this confirms that a value is a float, int or valid numeric string)
Zeljko Porobija
11,491 PointsYep, I missed an ! before is_float, it seems that it was the problem.
Zeljko Porobija
11,491 PointsZeljko Porobija
11,491 Points