Question: Swift: Write a new if-else statement that also checks to see if `nameInCaps` and `name` are the same. However, this time use the `lowercased()` method
Swift:
| Write a new if-else statement that also checks to see if `nameInCaps` and `name` are the same. However, this time use the `lowercased()` method on each constant to compare the lowercase version of the strings. If they are equal, print the following statement using string interpolations: | |
- "![]() |
Exercise - String Equality and Comparison Create two constants, nameInCaps and name. Assign nameInCaps your name as a string literal with proper capitalization. Assign name your name a string literal in all lowercase. Write an if-else statement that checks to see if nameInCaps and name are the same. If they are, print "The two strings are equal", otherwise print "The two strings are not equal." Write a new if-else statement that also checks to see if nameIncaps and name are the same. However, this time use the lowercased () method on constant to compare the lowercase version of the strings. If they are equal, print the following statement using string interpolations: " " and are the same." If they are not equal, print the following statement using string interpolation: - "> and > are not the same." Imagine you are looking through a list of names to find any that end in "Jr." Write an if statement below that will check if j unior has the suffix "Jr.". If it does, print "We found a second generation name!" let junior = "Cal Ripken Jr." Suppose you are trying to find a document on your computer that contains Hamlet's famous soliloquy written by Shakespeare. You write a simple app that will check every document to see if it contains the phrase "to be, or not to be". You decide to do part of this with the contains (_:) method. Write an if statement below that will check if textTosearchThrough contains textTosearchFor. If it does, print "I found it!" Be sure to make this functionality case insensitive. 28 import Foundation 29 let textToSearchThrough = "To be, or not to be--that is the question" 30 let textToSearchFor = "to be, or not to be" Print to the console the number of characters in your name by using the characters and count properties on name
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts

