Display value of variable with line-breaks when populated from javascript

Jun 27, 2023

I'm working on a template project where the variables get populated from a javascript that defines and adds the values to the variables.

There is one variable that will often be quite long. I want to include js code that will add a break every 3 lines. But can't do it.

Any ideas?

 

6 Replies
Math Notermans

Looks solid. Recapping how i think it works ( should work ) checking your images.

- sentences are split on a .
- all sentences are added to formattedCxScenario
- a . is added to the end.
- i is checked
- when (i +1) % 3 === 0 it will return true
- when true a <br> is added.

Looks correct...
I would add a console.log("i : "+i);
to check if i is the value you need... 
add it just before the if and in the check...so you can see the result.