# Uncaught TypeError: Cannot read property 'x' of undefined (sketch: line 36)

**URL:** <https://discourse.processing.org/t/uncaught-typeerror-cannot-read-property-x-of-undefined-sketch-line-36/10462>\
**Category:** Coding Questions\
**Created:** [April 19, 2019, 4:57pm UTC](https://discourse.processing.org/t/uncaught-typeerror-cannot-read-property-x-of-undefined-sketch-line-36/10462 "2019-04-19T16:57:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![replicant2021](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@replicant2021](https://discourse.processing.org/u/replicant2021)\
**Post date:** [April 19, 2019, 4:57pm UTC](https://discourse.processing.org/t/uncaught-typeerror-cannot-read-property-x-of-undefined-sketch-line-36/10462/1 "2019-04-19T16:57:45Z")

</div>

Hello there. I am making a code for Travel Salesman Problem but i got this issue

function draw() {  
background(0);  
for (var i = 0; i \< cities.length; i++) {  
ellipse(cities[i].x , cities[i].y, 8, 8);  
}

stroke(255)  
strokeWeight(2)  
noFill();  
beginShape();  
for (var i = 0; i \< order.length; i++) {  
var n = order [i];  
vertex(cities [n].x, cities [n].y);  
}  
endShape();

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [April 20, 2019, 1:05am UTC](https://discourse.processing.org/t/uncaught-typeerror-cannot-read-property-x-of-undefined-sketch-line-36/10462/2 "2019-04-20T01:05:41Z")

</div>

please also show where you define and fill array order and array ( of PVector / class ) cities

generally use print to show what you have like about  
i , n, cities[n]
