# Custom block with Javascript

**URL:** <https://forum.makecode.com/t/custom-block-with-javascript/13876>\
**Category:** micro:bit extensions\
**Tags:** extension\
**Created:** [May 31, 2022, 11:58pm UTC](https://forum.makecode.com/t/custom-block-with-javascript/13876 "2022-05-31T23:58:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maciek21](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Maciek21](https://forum.makecode.com/u/Maciek21)\
**Post date:** [May 31, 2022, 11:58pm UTC](https://forum.makecode.com/t/custom-block-with-javascript/13876/1 "2022-05-31T23:58:21Z")

</div>

Hi guys!  
I am writing, because I have one question:  
Is it possible to create a logic custom block like “if”? I know that there are already logic block in Makecode, but I would like to create my own logic blocks like “if”, “if else” etc. Do you think it is possible? If yes please let me know how it should look like. I will be very very thankful:)  
Have a nice day!

---

<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:** [June 1, 2022, 12:06am UTC](https://forum.makecode.com/t/custom-block-with-javascript/13876/2 "2022-06-01T00:06:38Z")

</div>

**Short answer** : No. You can add new blocks to the logic category but you can’t override any of the builtin ones like if/else

**Longer answer** : kinda, but it won’t be pretty

There are two key features of if/else that are not supported in custom blocks from extensions:

1. They expand with multiple statement inputs (i.e. multiple “mouths” that you can put blocks in)
2. They compile to actual if/else statements in TypeScript. All custom blocks must compile to a function call, so they can’t turn into a raw if/else statement (or any other language construct for that matter)

That being said, you can make something sort of like an if/else by making several different blocks that take in a boolean and a handler. That’s probably not what you’re looking for though.

Can you provide a little more information about what you want to achieve? Maybe a drawing of what you want the block to look like?

---

<div class="post-metadata">

**Author:** ![Maciek21](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Maciek21](https://forum.makecode.com/u/Maciek21)\
**Post date:** [June 2, 2022, 4:06pm UTC](https://forum.makecode.com/t/custom-block-with-javascript/13876/3 "2022-06-02T16:06:49Z")

</div>

Well, I would like to create the same block as “if” block that already exist. I need this just to make a program for DFRobot Maqueen Plus with Micro:bit V2. The reason I want to do this is because I would like to make this program with as many custom block as I want.
