TypeScript => APCSP PseudoCode Generator

JavaScript


let name = INPUT("What is your name?");
if (name === 'Alice') {
DISPLAY('Welcome to Wonderland!');
} else {
DISPLAY('Why hello, ' + name + '!');
}


Line 1: name ← INPUT("What is your name?")
Line 2: IF name = "Alice" THEN 
Line 3: {
Line 4:   DISPLAY("Welcome to Wonderland!")
Line 5: }  ELSE
Line 6: {
Line 7:   DISPLAY(CONCAT(CONCAT("Why hello, ", name), "!"))
Line 8: }

How to Use

Just type JavaScript in the JavaScript side, and you should see code appear on the right. If I implemented the syntax you're using (which should be most syntax), it should show up translated into APCSP code.

We also support some APCSP functions, such as RANDOM, DISPLAY, and INPUT.

Input/Output

If you want to test out some simple input/output code, you can use DISPLAY and INPUT, or if you want it to feel more like JavaScript, I've made aliases for those as prompt and display.

Robot Code

I've also inputted APCSP style robot code, which you can access by calling methods such as ROTATE_RIGHT or MOVE_FORWARD or the more JS-like alternatives I've put in which are forward(), right(), left(), etc.

For problems, try typing:

  • PROBLEM_1()
  • PROBLEM_2()
  • PROBLEM_3()
  • etc.

The full list of robot functions is:

  • forward() or MOVE_FORWARD()
  • left() or ROTATE_LEFT()
  • right() or ROTATE_RIGHT()
  • canMove() or CAN_MOVE()
  • goalReached() or GOAL_REACHED()

Some structures, such as objects, aren't supported in the APCSP syntax, so YMMV.

List Methods

If you want to be impressed with my overachieving in creating this tools, take some of the list methods for a spin.

For example, the following code fragments should work.


let fruits = ['apple','pear','persimmon','banana'];
let pfruits = fruits.filter(fruit => fruit[0]=='p');

List methods I've implemented include:

  • forEach
  • map
  • filter
  • some
  • includes
  • find