#What am I doing wrong?

16 messages · Page 1 of 1 (latest)

silver hawk
hardy waspBOT
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
silver hawk
const [iAmount, iFlag] = vIC.split("_");


console.log("------------------------");
console.log(vIC);
console.log("------------------------");
console.log(iAmount);
console.log("------------------------");``````
------------------------
+ 3.000_IC
+ 3.100_IC
+ 3.200_IC
------------------------
+ 3.000
IC
+ 3.100
------------------------```

Why might this happen?

Please ping me when you answer

It looks like it works when I do this:```js
const [iAmount, iFlag, iDay, iDescription] = vIC.split("");
const [pAmount, pFlag, pDay, pDescription] = vPE.split("
");
const [nAmount, nFlag, nDay, nDescription] = vNE.split("_");

console.log("------------------------");
console.log(vIC);
console.log("------------------------");
console.log(iAmount, iFlag, iDay, iDescription);
console.log("------------------------");
console.log(iAmount);
console.log(iFlag);
console.log("------------------------");

------------------------
+ 3.000_IC
+ 3.100_IC
+ 3.200_IC
------------------------
+ 3.000 IC
+ 3.100 IC
+ 3.200 IC
------------------------
+ 3.000
IC
+ 3.100
------------------------```

But why?

vital mural

i'm not seeing the issue

vIC is a string with 3 lines

the ----- make it quite clear

+ 3.000_IC
+ 3.100_IC
+ 3.200_IC
```this entire chunk is `vIC`

if you rewrite it as a string:
"+ 3.000_IC\n+ 3.100_IC\n+ 3.200_IC"
you're just splitting on _, so you get
+ 3.000, IC\n+ 3.100, IC\n+3.200, IC

you then take the first 2 elements and print them, + 3.000 and IC\n+ 3.100

that yields the output you're getting

idk what you're expecting

silver hawk

oooh okay ty
So I need to split it into sentences first