Redacted!

I Iteration Obfuscation

i. What you’ll be building 1/6

Save and Submit

ii. Getting the User’s Input 2/6

puts "What is your name?"
text = gets.chomp
puts "What is your brother's name?"
redact = gets.chomp

iii. The .split Method 3/6

puts "What is your name?"
text = gets.chomp
puts "What is your brother's name?"
redact = gets.chomp
words = text.split(" ")

iv. Redacted! 4/6

puts "What is your name?"
text = gets.chomp
puts "What is your brother's name?"
redact = gets.chomp
words = text.split(" ")
words.each do |name|
 print name
end

v. Control Flow Know-How 5/6

puts "What is your name?"
text = gets.chomp
puts "What is your brother's name?"
redact = gets.chomp
words = text.split(" ")
words.each do |name|
 if name == redact
 print "REDACTED "
 else
 print name + " "
end
end

vi. Great Work! 6/6

Save and Submit!

Advertisements

2 thoughts on “Redacted!

  1. The logic is to hide the password by printing something else in place of it. For example, after running the code for 5/6, in the first input type in ‘I love icecream’ and in the second input type in ‘love’ (think of ‘love’ as the password). ‘love’ will be replaced by ‘REDACTED’.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s