# JavaScript won't translate back to blocks

**URL:** <https://forum.makecode.com/t/javascript-wont-translate-back-to-blocks/11786>\
**Category:** Adafruit Circuit Playground Express\
**Created:** [January 19, 2022, 5:10pm UTC](https://forum.makecode.com/t/javascript-wont-translate-back-to-blocks/11786 "2022-01-19T17:10:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick314](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/rick314/32/5621_2.png) [@Rick314](https://forum.makecode.com/u/Rick314)\
**Post date:** [January 19, 2022, 5:10pm UTC](https://forum.makecode.com/t/javascript-wont-translate-back-to-blocks/11786/1 "2022-01-19T17:10:56Z")

</div>

JavaScript code generated from MakeCode blocks won’t always translate back to blocks. Is this a MakeCode defect or documented somewhere as expected behavior?

Details: I am using an Adafruit Circuit Playground Express and [https://makecode.adafruit.com](https://makecode.adafruit.com) in a Firefox browser to program it. I had a problem in a larger program and reduced it to the following. Enter these blocks.  
 ![MakeCodeIssue1](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c94c17a8cfbf37295c268d19307ad9dfc8e5d9ad.png)  
Switch to the JavaScript view and see this code.

```auto
let MyColors = [Colors.Red, Colors.Orange]
let MyNotes = [523, 587]
light.clear()
light.setPixelColor(0, MyColors[0])
music.playTone(MyNotes[0], music.beat(BeatFraction.Whole))

```

Going back and forth between Blocks and JavaScript at this point is no problem. _Start a new empty project_, go to the JavaScript view, and paste in the JavaScript. It simulates fine and all is well so far. But switch to the Blocks view and see the next image. I had to be quick with a screen capture to get the image because the warnings go away in a few seconds. (This is a separate issue – Why do the warnings go away soon after being displayed?)  
 ![MakeCodeIssue3](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/d/dd6b01bf3796cd6c544ed2c586e6589533455015.png)  
Notice “Colors.red” and “523” instead of “red” and “High C” as were seen before. Then trying to go back to the JavaScript view fails with “Oops, there is a problem converting your code.” The JavaScript can no longer be seen.

I can understand perhaps seeing in the block view that “red” and “High C” are replaced by their RGB and Hz values (similar to how JavaScript “0xff” becomes “255”). But it doesn’t seem right that JavaScript generated from MakeCode blocks gives errors (that then go away but are still really there) when converted back to blocks.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [January 24, 2022, 7:20pm UTC](https://forum.makecode.com/t/javascript-wont-translate-back-to-blocks/11786/2 "2022-01-24T19:20:17Z")

</div>

Yep, this is a bug! Thanks for reporting it!

I have created a PR to fix the grey blocks here:

> <https://github.com/microsoft/pxt-common-packages/pull/1313>
>
> Reported here: https://forum.makecode.com/t/javascript-wont-translate-back-to-bl…ocks/11786
