# JS code returns value in console, but not in Katalon

**URL:** <https://forum.katalon.com/t/js-code-returns-value-in-console-but-not-in-katalon/176898>\
**Category:** Miscellaneous\
**Created:** [June 25, 2025, 2:10am UTC](https://forum.katalon.com/t/js-code-returns-value-in-console-but-not-in-katalon/176898 "2025-06-25T02:10:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kjackey1](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kjackey1/32/30227_2.png) [@kjackey1](https://forum.katalon.com/u/kjackey1)\
**Post date:** [June 25, 2025, 2:10am UTC](https://forum.katalon.com/t/js-code-returns-value-in-console-but-not-in-katalon/176898/1 "2025-06-25T02:10:40Z")

</div>

Trying to validate that a particular element was found and selected on a highcharts graph, I have the JS working in the console but Katalon’s not recognizing the return value and I can’t figure out why.

Here’s the JS code:

```auto
(() => 
{
	var el = document.getElementById('page-views-scatter-plot-graph');
	var chart = Highcharts.charts.find(c => c && c.renderTo === el);
	var outerLength = chart.series.length;
	var itemClicked = false;
	for(var i = 0, lo = outerLength; i < lo && !itemClicked ; i++){
			var innerLength = chart.series[i].data.length;	
			if (innerLength > 0) {		
				for(var c = 0, li = innerLength; c < li && !itemClicked; c++){
				var point = chart.series[i].points[c];
					if ((point.options.marker?.symbol ==='diamond') && (point.color === 'green')) {
						point.firePointEvent('click');					
						itemClicked = true;					
						return itemClicked;				
					}		
				}		
			}
	}

	return itemClicked;
				
})();

```

Screenshot of it working in the console:

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/d/3/d3e2daca5a210ed0093dee13a2fc089c929cf48c.png)

Katalon Execute JS statement:

```auto
		String jsvaluefound = WebUI.executeJavaScript(javascript_statement, null)
		KeywordUtil.logInfo("jsvaluefound = " + jsvaluefound)

```

Katalon variable value after executing this portion:

```auto
![image|690x19](upload://8fUoJQ8vjl8Yyz1C1mU9XTB8mOW.png)

```

This is likely one of the more complex things I’ve had to do using Katalon JS executes; however I’m a bit stumped as usually if I get the console side to work the JS value is returned correctly as well, thoughts?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [June 25, 2025, 2:31am UTC](https://forum.katalon.com/t/js-code-returns-value-in-console-but-not-in-katalon/176898/2 "2025-06-25T02:31:44Z")

</div>

> [@kjackey1](#):
>
> Katalon variable value after executing this portion:
> 
> ```auto
> ![image|690x19](upload://8fUoJQ8vjl8Yyz1C1mU9XTB8mOW.png)
> 
> ```

??? I can`t see the image.

Please erase the pair of triple back ticks around the `![image|...`
