r/JavaScriptTips • u/fare03 • Aug 30 '22
Javascript help
Please guys I need help, I need to split string into array with students.
'Ebonie Range 7175 Yukon Street (507) 833-3567 Geography Keenan Ellwood 2 Elm Lane (894) 831-6482 History Kailan Smart 795 Harvard Street (925) 856-5167 Biology Kaydan Hirst 9 East Lakeview Ave. (939) 812-6141 Programming Isabelle Prentice 700 Rock Maple St. (899) 875-8627 Math'
I need to split it into object for every single student for example:
Name: Ebonie Rangel
Address: 7175 Yukon Street
Phone: (507) 833-3567
Course: Geography
but for every student, please help.
i split it like this var array = text.split("\n",4)
but how i can split from 4 to 8 for example.
Thank you <3.
0
Upvotes
1
u/[deleted] Sep 02 '22
I’m not able to try this now but I think you will need to use array.slice() to accomplish this. Check out the MDN documentation on that