Why is the split() method not working? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
16th Jun 2022, 2:20 PM
Muhammad Awwal Yusuf
Muhammad Awwal Yusuf - avatar
9 Respostas
16th Jun 2022, 4:12 PM
JaScript
JaScript - avatar
+ 1
// If you add at the end of your code console.log (arrr); // you will see why it is not working // the question is what do you try to do in your code?
16th Jun 2022, 2:48 PM
JaScript
JaScript - avatar
+ 1
JayakrishnašŸ‡®šŸ‡³ I edited the code, check the types out, it says string and object(array) and not no
16th Jun 2022, 2:53 PM
Muhammad Awwal Yusuf
Muhammad Awwal Yusuf - avatar
+ 1
JaScript , I want a comma separated output with a number type.
16th Jun 2022, 2:54 PM
Muhammad Awwal Yusuf
Muhammad Awwal Yusuf - avatar
+ 1
You can do like this: var arr = [2, 3, 7, 8]; var arrr=[]; arr.forEach(function(el) { arrr+= el * 2 +","; }); console.log(arrr); // or console.log(arrr.substr(0,arrr.length-1)) console.log(arr.join(",")) //i think, you may trying to join, not split. hope it helps..
16th Jun 2022, 5:07 PM
Jayakrishna šŸ‡®šŸ‡³
16th Jun 2022, 5:16 PM
Muhammad Awwal Yusuf
Muhammad Awwal Yusuf - avatar
+ 1
Muhammad Awwal Yusuf You're welcome.. (I edited code a bit more, see again..)
16th Jun 2022, 5:19 PM
Jayakrishna šŸ‡®šŸ‡³
0
You have single value in the array arrr!! And you have " , " in your values so split method does not affect... you have only numbers..
16th Jun 2022, 2:49 PM
Jayakrishna šŸ‡®šŸ‡³
0
I just want an output that bring the no with comma
16th Jun 2022, 2:53 PM
Muhammad Awwal Yusuf
Muhammad Awwal Yusuf - avatar