There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
hello
Could someone help me? I am doing the " Race Day Project" and it is going well except my ‘string interpolation’ part. It didn’t execute whenever I used ‘string interpolation’ code. It is happened not only in this project but also another project so I think something is wrong. Please see my quotes below. I tried with many different ways like ‘copying exact words from hint section’ or ’ copying exact string interpolation code from other projects ’ but still it didn’t execute. I don’t know where is wrong ? is something I need to download to execute ‘string interpolation’ or to work well ‘string interpolation’ code? Could someone advise what to do ? There is nothing wrong other parts of code and all runs well.
thanks
It showed code but not a number ( please see below )
they will race at 11:00 am. Their raceNumber is ${raceNumber}
let raceNumber = Math.floor(Math.random() * 1000);
const registeredEarly = false ;
let runnerAge = 20;
if (runnerAge >18 && registeredEarly ) {
raceNumber += 1000 ;
}
if (runnerAge>18 && registeredEarly) {
console.log (‘they will race at 9:30 am. Their raceNumber is {raceNumber}');
}
else if (runnerAge >18 && !registeredEarly)
{console.log ('they will race at 11:00 am. Their raceNumber is {raceNumber}’);
}
else if (runnerAge <18) {
console.log(‘they will race at 12;30 pm. Their raceNumber is ${raceNumber}’);
}
else
{
console.log(‘the runner needs to see the resigtration desk.’);
}
Hi @arc2779423039 , I’m assuming you are long past this by now but just in case anyone else was wondering - this looks more like JavaScript than Swift. For example, there’s no console.log() function in Swift, you’d want print() instead.
Additionally, the interpolation syntax is different in Swift as well: let runnerAge = 20 print("The runner is \(runnerAge) years old
So I am on this section of the lessons and I am a bit confused. What is the point of string interpolation when you can just type it out. For example the lesson shows
var albums = 17
print("Daniel Johnston made \(albums) studio albums.")
With the result being: Daniel Johnston made 17 studio albums.
However when I typed in the editor
print("Daniel Johnston made 17 studio albums.")
I got the same result as when I typed it using string interpolation. Is string interpolation used mainly for more complicated things like adding Int and strings and doubles all into the same line of code??? Also I used code byte to show code however it doesn’t give me the option of choosing swift.
Yeah, for other situations that could either be more complex or depend on the information that will be entered by the user.
Let’s say for example you want to create a calculator that tells how old your user is.
So the user could enter their date of birth, and your program would determine their age and store the result on the variant “age”.
Then you can use the example from this exercise and it would work.