I want to make a list number maker or generator, | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11

I want to make a list number maker or generator,

If i add some text in textarea, like a How are you? I'm fine. What are you doing? Nothing special. And after clicking on submit Button it's show me.... like a... 01 : How are you? 02 : I'm fine. 03 : What are you doing? 04 : Nothing special. Please help me. https://code.sololearn.com/Wd8VxRHQr5hQ/?ref=app

10th Jul 2021, 5:17 PM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar
12 Answers
+ 4
Ayesha Noor This might help you ! var btn=document.querySelector(".btn"); var textArea=document.querySelector(".txt"); btn.onclick=()=>{ a=textArea.value.split("\n"); text=""; index=0; for(i of a){ if(i!=""){ text+=`0${index}:${i}\n`; index+=1; } else{ text+="\n"; } } textArea.value=text; }
10th Jul 2021, 6:51 PM
Abhay
Abhay - avatar
+ 3
You have learned almost all programming Languages from sololearn and you can't even do that ?? 🤨🤨 haven't you learned anything ?? And if you have learned something, then where is your attempt ??
10th Jul 2021, 5:59 PM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
10th Jul 2021, 6:03 PM
Jp (Jay )
Jp (Jay ) - avatar
+ 2
I want a list maker code...
10th Jul 2021, 5:24 PM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar
+ 2
Sorry , just noticed that you want the output in that format that is mentioned at last in description.
10th Jul 2021, 6:51 PM
Abhay
Abhay - avatar
+ 2
Abhay, thanks
10th Jul 2021, 6:58 PM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar
+ 1
I don't understand what are you looking to do with that code !
10th Jul 2021, 5:22 PM
Abhay
Abhay - avatar
+ 1
What exactly do you mean by list maker code ? Can you please elaborate on what it should do when submit button is clicked!
10th Jul 2021, 5:30 PM
Abhay
Abhay - avatar
+ 1
Aap Hindi Mein Baat Kar Sakte Hain?
10th Jul 2021, 5:35 PM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar
+ 1
Read text and split to array.. var textArea = document.getElementById('textAreaId'); var lines = textArea.value.split('\n'); for (var j = 0; j < lines.length; j++) { console.log((j +1)+ ' : ' + lines[j]) } Hope it helps...
10th Jul 2021, 6:08 PM
Jayakrishna 🇮🇳
- 4
Hai
11th Jul 2021, 5:10 PM
Ajay Ajay
- 4
(Ayesha haii I like to,,,, ...)!!!
11th Jul 2021, 5:20 PM
Ajay Ajay