Skip to content

Latest commit

 

History

History
 
 

31-Project24

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Project 24 - Swift Strings

https://www.hackingwithswift.com/100/80

Includes solutions to the challenges.

This is a playground project.

Topics

Strings, NSAttributedString

Challenges

From Hacking with Swift:

  1. Create a String extension that adds a withPrefix() method. If the string already contains the prefix it should return itself; if it doesn’t contain the prefix, it should return itself with the prefix added. For example: "pet".withPrefix("car") should return “carpet”.
  2. Create a String extension that adds an isNumeric property that returns true if the string holds any sort of number. Tip: creating a Double from a String is a failable initializer.
  3. Create a String extension that adds a lines property that returns an array of all the lines in a string. So, “this\nis\na\ntest” should return an array with four elements.