0
Split
Why is my split not working? How do I make it so every number has a space between them https://code.sololearn.com/WQ9E4w5065f6/?ref=app
8 Réponses
+ 1
Yes string concantenation would work, but you need to convert the input to numbers using parseInt() first.
Here is a demo for your version:
https://code.sololearn.com/WfuTBfLSx2vq/?ref=app
For Ipang's array version, you need push() and join()
Here is a demo of Ipang's version:
https://code.sololearn.com/WyXpYf9cbK1R/?ref=app
These simple projects help embrace your JS skill, keep up 💪
P.S. I don't like your current SoloLearn profile name, it is rude and harrassing.
0
Illustrate the inputs and expected output please.
About split(), it is a method that is implemented in string class. But <numq2> is a Number not a string, so it's not possible to split s Number, except where the Number is converted to string first.
0
Okay. So i got rid of my parseInt so it should be a string now i think. Except not its saying parseInt is not a function and its undefined
0
You still not telling me what expected output should be, given a certain inputs ...
0
Okay so basically. Whenever you go through all the questions. The min and max question is for how many numbers you want. For example if i say the min is 10 and max is 20 WITH SPACES. I want the output to be
10 11 12 13 14 15 16 17 18 19 20
0
I guess you have two options ...
1. Use an array, fill it up with numbers in range, then use string.join() method to glue the elements into a string.
2. Use an empty string, and concatenate each number in range to the string.
There could be another way, these are just what I had in mind ...
0
Idk if this could work i dont rlly know how to put it into code rlly. But what is i was thinking was using another while loop. For every number there would a “,” so maybe like numq2 += “,” im not to sure
0
Or i could just put numq2 += “ “