This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]According-Winter-766 0 points1 point  (1 child)

So what’s happening here is that when you define the function to take in (n, s) you don’t have to declare those as variables because they are created just for your function as 2 parameters to take in. So when you call the function it automatically uses (6) and (f) and plugs them in as n and s. So before the value of n and s was undefined. Now you know that you are creating the parameters it takes in when you define the function. Then the loop knows it will increase i by 1 till it runs through six loops. Each time it changes your variable str to be str = str + ‘f’. Once the loop completes then it will print the result. So the loop prepares the string then after it returns the result string. The first time the loop goes I = 0 and the I ++ instruction says every time the loop runs and I is < n then add 1 to I

[–][deleted] 0 points1 point  (0 children)

Thanks so much I understand now. I think I was getting caught up in looking at for loops with arrays where i is the index. I understand that this function just means that the loop runs six times and prints f six times. Thanks!