-
-
Save rvbsanjose/3823543 to your computer and use it in GitHub Desktop.
pseudocode
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
Script: CONVERT EVERY OTHER LETTER OF A SENTENCE TO CAPITAL LETTERS | |
GET a sentence from user input | |
IF the word starts with a capital letter, don't change it | |
ELSE convert every other letter to capital letters | |
ENDIF | |
PRINT the formatted sentence | |
def new_pseudo | |
sentence = gets.chomp | |
if sentence.start_with?(sentence[0].upcase) | |
sentence | |
else | |
words = sentence.split(' ') | |
words.each do |word| | |
(1..word.length - 1).step(2) do |index| | |
word[index] = word[index].upcase | |
end | |
end | |
words.join(' ') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment