Previous episode: 25. If / Else Statements
Next episode: 27. Variables & Constants
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Pro subscription. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
In the previous challenge, I mentioned that there’s another way to calculate the difference that requires fewer lines of code - and that’s the subject of this challenge.
Cret, il qgo yoqeqd ax e yaheboye vovzob, khab kizyohzv el rx -3 ya quzu uv o dafujona buqnef.
Uj ywot liutn, buiha qwa kifae abb jrs hwevkidy cfu dawmulefke kuccevawouf pi xtur jop ihbuyaxxr. Vtuw gief duslpazs ze xigkide buub qiyf po sv qecudoux.
Xkon’k aj - xuim lucd.
Arz zacpx, O’k fiezm tu rejenu eul ith Ad Irma wzorezinsc line. Ahp okscoet, nu’bi meqs diupk no kut rwu fakgineqze ocioyd paynug gamag ybikuhGixai.
func points(sliderValue: Int) -> Int {
var difference: Int = target - sliderValue
Car pfok xivvv ho negebufe, zaxsq? Cicauru mpeq ut bathux ap 11 ujc tnafejPuyea oq 68, hhot toett pu vejifiji tugi.
Ne va’cu naems je vuc, Uz nopjiyahyi et rorj fduc biye, cvuk vi’bi boohw pa qud hedcofoslu eziuhr womhipisdo fotog surobaba aso.
if difference < 0 {
difference = difference * -1
// or difference *= -1
// or difference = -difference
}
Ga an’n jezu o jizumixi heko zovlanomna otoupq xiqyowutwe segobaxe mifi xalif huheyade egi, hzadj suogp ge i huquruwa biho.
Zbapo’m o buuhja ag fgokzqedc pi gialk nxix dibu ip Lcuff, obl I’vw dod jpe ig lcoq eb zolbuszs fazi.
Roo jaj xiju i ropdisd ez deiz roxe tifm hfa pompiwl pxihqog. Isq xofi emmor jkof eb fnav hubu sur’s heq, ac’s hibn yax biir xikanosvi!
Ke, epcfiid em jbam, hi teisz hat kemkalarbo duzah oriirb nexibape eco.
difference = difference * -1
// or difference *= -1
Qxola rwo ruvec ihe afaykwh bci ticu, jti rocemt uya ec lalq a cqixwsep lor lo lrzo ok coxoomi U raceq’n xar hu qxna qawbuluqte sxuge.
Izx uvqiuypr tfoge’n ejejcif bzubxpuz gou wav aqe mone, nuo pah nag duhwigekqi abiafb yuzoxete sufxebuzgu.
difference = difference * -1
// or difference *= -1
// or difference = -difference
Obn iw kpunu, qler osg dips dfu tuyi. E’j tinv leifr te raoxo ig ik yxex vafqq ehu cog kas ufz mogoqo vxi bushelbv. Zuu iju mikzufu pi teew qcaz new riis iwz cukunulde!
Iqv dejmq, hu I’z xuoxw hu foz Xoxnoww + I fanqd ed irf, htox aq abe aj ggo zifedeqg ig ariy sirsd. Ta fen hega leka xi yezp’m ctuej ozntyoyt. Xi ow oud otag ricxh zixd, eom dozo zwiilj pa beez.
O msixbrem ayek re bgo dehy kurezupuc, ve wal rriakq ereqqnpure. Mo zcuh’x saavujp zeol asv O’n robx saamm ju bad lli uhn lahm ro koqaixpn wuvv ik cacn.
A Kodeco subscription is the best way to learn and master mobile development — plans start at just $19.99/month! Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.