GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

Day 2 checkpoint

Forums > 100 Days of SwiftUI

Hi all,

I am having problems with the day 2 checkpoint. it seems to complex for me to understand in my second day. could someone help me with the correct code (as simple as it can get) so I can look at it?

2      

import Cocoa

let fellowship = ["Frodo", "Sam", "Pippin", "Merry", "Gandalf", "Aragorn", "Legolas", "Gimli", "Boromir", "Frodo", "Sam", "Gollum"]

// Making a set of the array removes duplicates because Sets can't have duplicates
let uniqueFellowship = Set(fellowship)

// Printing the number of elements in the array fellowship
print(fellowship.count)

// Printing the number of elements in the set uniqueFellowship
print(uniqueFellowship.count)

2      

let lettersArray = ["A", "A", "B", "A", "C", "D", "A"]
print(lettersArray.count)
// Prints - 7

// Making a set of the array removes duplicates because Sets can't have duplicates
let uniqueLettersArray = Set(lettersArray)

print(uniqueLettersArray.count)
// Prints - 4

print(uniqueLettersArray)
// Prints - ["A", "C", "B", "D"]

2      

weird! thats not the day 2 i am trying to do. my checkpoint-test is about celcius and fahrenheit converter.

2      

Ah sorry, I read checkpoint 2 instead of day 2 checkpoint

2      

import Cocoa

//Create a constant holding any temperature in Celsius
let celsius = 30.0

//Convert that to Fahrenheit by multiplying by 9, dividing by 5, then adding 32
let fahrenheit = ((celsius * 9) / 5) + 32

//Print the results for the user, showing both the Celsius and Fahrenheit values
print("Degrees Fahrenheit: \(fahrenheit)° F")
print("Degress Celsius: \(celsius)° C")

//Convert it back bonus
let convertedBackToCelsius = ((fahrenheit - 32) * 5) / 9
print("Degress Celsius: \(convertedBackToCelsius)° C")

3      

Hacking with Swift is sponsored by try! Swift Tokyo.

SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!

Get your ticket here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.