Hello, all! I've been working with our kiddo to learn programming using the Circuit Playground Express. It's been going great so far, but we have hit a bit of a snag. Earlier today, we started (trying) to use arrays and they don't seem to work the way we expected. Here is an example of what we're seeing:
- error makecode.png (24.21 KiB) Viewed 129 times
Note that we define the array at start, and then try to append inside a user defined function. However, the Javascript that Makecode generates is flawed:
- error javascript.png (7.69 KiB) Viewed 129 times
You'll note that the array is defined as a number, then assigned as an array. But in the user defined function, it doesn't know how to push -- the error the tooltip shows is "Property 'push' does not exist on type 'number'."
If in the Javascript view, I correct the code to read:
Code: Select all
function doSomething () {
list.push(4)
}
let list = [1, 2]
The error goes away, but as soon as I pop over to Blocks mode, it breaks again.
What am I doing wrong? Any ideas? It sort of feels like a bug, but I am not confident enough in what I'm doing to say that for sure.