# Variable pollution across objects from class

**URL:** <https://discourse.processing.org/t/variable-pollution-across-objects-from-class/17221>\
**Category:** Libraries\
**Created:** [January 21, 2020, 11:46am UTC](https://discourse.processing.org/t/variable-pollution-across-objects-from-class/17221 "2020-01-21T11:46:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marloguer](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@marloguer](https://discourse.processing.org/u/marloguer)\
**Post date:** [January 21, 2020, 11:46am UTC](https://discourse.processing.org/t/variable-pollution-across-objects-from-class/17221/1 "2020-01-21T11:46:59Z")

</div>

Hello, Im new to p5.js but am using it via the react-p5-wrapper for data-visualisation within a react webapp…

I can successfully render ‘strings’ to screen such that a string starts off-screen-right at a random yPosition with a random textSizesuccessfully then tracks across screen until it goes off-screen-left to then restart off-screen-right with a new string, a new random yPosition and new random textSize.

However when I implement a ‘class’ so as to render multiple strings at once I run into variable pollution whereby every new off-screen-left update updates ALL instantiated objects (see sketch.js & class.js code below)…

> <https://github.com/3pin/letsfakenews/blob/visuals/client/src/app/pages/watch/sketches/sketch4class.js>

> <https://github.com/3pin/letsfakenews/blob/visuals/client/src/app/pages/watch/sketches/classes/class.js>
