Wednesday, June 15, 2022

Js - Canvas for start

By that snippet we can conclude is that canvas in JavaScript isn't a reserved word, or would not be possible use canvas to name a variable.

const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(10, 10, 100, 100);

And other for text field or for an prompt in JavaScript, I was making for prompt when the number be 0, would the program stoped to ask more one number but wasn't working because that line of command:

while (sayNumber !==0)

And why because with the comparision what collect the prompt is text and not number, they have the same value but not the same type, so one thing that would help me would compare that way 

sayNumber != 0 

and this way would be true '0' == 0, another I don't know why more academic way is write keep the 

sayNumber !== 0

like this but say:

let sayNumber = Number(prompt('say a number'));

Something that I didn't tryed was while(sayNumber !== '0');

And one thing that would help yuo learn programming is notice that some commands in the examples of the Mozilla, that is complete but not friendly is that you are reading something basic, but the names are so fancy that you think that is new matter like function swap() you gonna think that is a method that you need learn but isn't, is a function like the ones that you can do, but the name was so impressive that gives that impression that is a method. Rute Bezerra de Menezes Gondim 



No comments:

Post a Comment