+ 30
Why is JavaScript in different learning apps different from each other?
I've learned js in Khanacademy for three years. When I came here, the basics are same, but some stuff are absolutely different. I'm really upset thinking that I've wasted my time... For example: in Khanacademy, fill(0, 255, 0); rect(200, 200, 20, 20); Drew a green rectangle. But in Sololearn code playground, it says rect and fill undefined...and many other problems. Am I unable to understand, or the types of js are different? Which one of them is right?
6 Respuestas
+ 10
Humayra_Islam:)🇧🇩
Hi don't be upset Js is same everywhere there no such thing like different js.
I bet sololearn is giving error because u need to wrap the code in: window.onload this is happening because the script must be executing before your DOM is read.
//Also please share your code in the question so that we can see what u are doing wrong
Like:
window.onload = function() {
//Ur code here
};
- - - - - -Based on your question- - - - -
window.onload = function(){
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d'); ctx.rect(10, 20, 150, 100);
ctx.fillStyle = "Green";
ctx.fill();
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
//See i have created a green rectangle for u:
https://code.sololearn.com/W9ATlimn5o0B/?ref=app
+ 23
Thanks, it helped🙂🙂
+ 23
Well, that's it... In Khanacademy, they didn't need a draw function...
Thanks, Arb Rahim Badsa for the help 🙂🙂
+ 8
Cbr✔ No
All programming languages has their own House to stay!
Means Every languages has their different path and syntaxs too!...
+ 7
JS is same everywhere! I can guess you might have learnt their the p5.js library! As you said,
fill(0, 255, 0);
rect(200,200,20,20);
Will create a green rectangle if you put them inside draw function! Just like this one :
https://code.sololearn.com/W2XXFPbT3WS4/?ref=app
+ 3
Humayra_Islam:)🇧🇩
You are welcome, Enjoy! 👍😄😆