# This is a solution a found of a question, here i dont understand what is the function of +

``````var decodeString = function(s) {

var currentNum = '';

var currentStr = '';

var arrNum = [];

var arrStr = [];

for(let i = 0; i < s.length; i++){

if(s[i] >= 0 && s[i] < 10){

currentNum += s[i];

} else if(s[i] == '['){

arrNum.push(currentNum);

arrStr.push(currentStr);

currentNum = '';

currentStr = '';

} else if(s[i] == ']'){

currentStr = new Array(+arrNum.pop()).fill(currentStr).join(''); //'+" what is this plus?

currentStr = arrStr.pop() + currentStr;

} else{

currentStr += s[i];

}

}

return currentStr;

};

console.log(decodeString("3[a2[c]]"));
``````

I donâ€™t understand what you are saying in the title. Can you please provide a link to what you are working on and more fully describe what you need help with? Thanks.

Iâ€™ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the â€śpreformatted textâ€ť tool in the editor (`</>`) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (â€™).

1 Like

Iâ€™m assuming this is the `+` youâ€™re talking about. This is a short-circuit way of coercing a value to a number. It is removing the last value from an array, and if it can, making it a numeric value.

1 Like

yes now that make sense, thanks a lot!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.