This file contains hidden or 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
| # your local variables | |
| first_card = 11 | |
| second_card = 13 | |
| # The "card" variable can only be seen within the method | |
| def check_face_card(card) # removed the space | |
| if card == 11 || card == 12 || card == 13 | |
| card = 10 | |
| else | |
| end |
This file contains hidden or 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
| class String | |
| def how_long_am_i? | |
| length = 0 | |
| while self[length] != nil | |
| length += 1 | |
| end | |
| length | |
| end |
This file contains hidden or 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
| # breaks if string includes a 0 | |
| def string_length(a) | |
| string = a + "0" | |
| length = 0 | |
| while string[length] != "0" | |
| length += 1 | |
| end | |
| puts "Your statement is #{length} characters long" |
NewerOlder