WebGL is an API currently based on the OpenGL ES 2 (embedded systems) standard. In order to access WebGL we need to get the WebGL context from the canvas element. The API serves as middleware between your application and the GPU drivers. This means that it is quite low level and there are several things you need to do to actually render your 3D scene.
Take a look at the base code located at:
https://cglearn.eu/files/course/1/tasks/HelloWebGL.zip
You will notice several important things there:
The coordinates that we use are in normalized device space. We are not doing any transformations on them, so a coordinate [0, 0, 0] will be in the middle of the viewport. The coordinate [-1, -1, 0] will be in the bottom-left corner and so on. Later we will see how to use transformations and projection to have a more intuitive coordinate space (that will later be transformed into normalized device space).
The task is the same as before. Draw an equilateral triangle that has a center positioned at the coordinates given into the drawTriangle(position) function.
The result should look something like the image on the right.
Correctly formatted code is expected. Please indent the code correctly and avoid bad coding practices, such as magic numbers.