Choose the Right Article
00:00 This lesson, we’ll decide whether to use a or an as the article. And this is going to be part of the function in here. Right after picking out all the other random words, you’ll need to write a bit of conditional logic here because you can’t predict beforehand what the first adjective is going to be, because that’s what you have to look at.
00:24 So in the poem schema, you have first article, and then followed by adjective number one. Adjective number one is what we need to focus on. We need to pick the first of the three adjectives that we randomly selected, and then figure out what’s the first character.
01:09 But this is the idea, right? This is the steps that you need to follow. And then depending on whether or not the first letter of the first adjective in the adjectives list is going to be starting with a vowel or not, the article is going to be a or an. Okay?
01:42 I want to go further than that because what I’m actually interested in is just the first character of the first adjective. So I will use double indexing and just continue here with another opening square bracket and another zero, and then closing square bracket.
02:29 So now I picked out the first adjective and got its first character. I did both of those in one step, basically, by doing this double index notation. And now I want to decide whether it’s a vowel or not.
else I want the article to be
"A", so the
else is if it’s not a vowel, if it doesn’t start with a vowel but with a consonant, then I want the article to be
"A". Okay, let’s try it out.
I’ll run it a few more times until we see whether it also works with a vowel. So there you go. We get
incredulous as the adjective. And then because this starts with an I, which is a vowel, the article now is
Become a Member to join the conversation.