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

23rd Jul 2022, 1:33 AM
Junior
Junior - avatar
8 Answers
+ 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.
23rd Jul 2022, 10:03 AM
Gordon
Gordon - avatar
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.
23rd Jul 2022, 4:47 AM
Ipang
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
23rd Jul 2022, 4:49 AM
Junior
Junior - avatar
0
You still not telling me what expected output should be, given a certain inputs ...
23rd Jul 2022, 4:57 AM
Ipang
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
23rd Jul 2022, 4:59 AM
Junior
Junior - avatar
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 ...
23rd Jul 2022, 5:04 AM
Ipang
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
23rd Jul 2022, 5:16 AM
Junior
Junior - avatar
0
Or i could just put numq2 += “ “
23rd Jul 2022, 5:16 AM
Junior
Junior - avatar