I have been working on a Fibonacci Sequence algorithm, but when it comes to contextualizing the words for the console's output, I wanted it to understand the difference between plural and singular values. I decided to create separate entities that are directly affected with plurals, and named them;
n_plural
i_plural
is_plural
I am sure you can see in the code below how it is meant to function. When I type in the number "1" in the console, everything works well and it says what it should; "The first iteration in the Fibonacci Sequence is:", but when I type in something like 111, it will say something like "The firsto iterations in the Fibonacci Sequence are:" and won't even register a number in between "first" and "iterations".
Where is it getting the letter "o" from at the end of "first"? Is there a way that I can insert integer n into the n_plural IF statement so that the integer will show as a string? I am sure that the problem is created at;
else {
n_plural= n;
Also, is there a smarter way to go about making plural context without creating separate string entities in my work?
As you can see, on line 25, if the user enters n as 1, the IF statement on line 19 makes the value on n_plural = "", which is essentially nothing, which means that if the user enters n as 1, it won't say "The first 1 iteration..." instead, it will ignore the "1" and just say "The first iteration..." but when a number above 1 is entered for n, such as 10, it should say "The first 10 iteration's'." Line 21 basically inserts n_plural the value on n, so that when it is called on line 31 it will present the actual number as opposed to "" when a value of one is entered.
But yeah, the missing space in line 31 is due to the fact that I can't turn the int into a string, if I could, I would slap on a " " before the int so that it will become a space and then the number.