def fullStack?(student)
backend = student[:knowsRuby] and student[:knowsSQL]
frontend = student[:knowsHTML] and student[:knowsCSS] and student[:knowsJavaScript]
backend and frontend
end
alice = { name: 'Alice',
knowsRuby: true,
knowsSQL: false,
knowsHTML: true,
knowsCSS: true,
knowsJavaScript: true }
bob = { name: 'Bob',
knowsRuby: true,
knowsSQL: true,
knowsHTML: true,
knowsCSS: true,
knowsJavaScript: false }
applicants = [alice, bob]
recommendations = []
recommendation = ''
applicants.each do |applicant|
recommendation = 'Invite!' if fullStack?(applicant)
puts "#{applicant[:name]}: #{recommendation}"
end
This code prints:
Alice: Invite!
Bob: Invite!
Why are both invited, although none of them should be? And how can you fix the code?
Alice: Invite!
Bob: Invite!
Why are both invited, although none of them should be? And how can you fix the code?
2 Responses
Once you fix the first described here, modify alice hash entry with 'knowsSQL: true' so that Alice will be invited.
Run the code and it prints:
Alice: Invite!
Bob: Invite!
Why?
Once you fix the first described here, modify alice hash entry with 'knowsSQL: true' so that Alice will be invited.
Run the code and it prints:
Alice: Invite!
Bob: Invite!
Why?
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.