Posts

Showing posts with the label Javascript

JS-Loop and If

   < Beginner JS >< Function >< Variable >< Loop-If >< OOP > if statement if(MemberAge<18){ document.write("teen"); } if..else if(MemberAge<18){ document.write("teen"); } else{ document.write("big"); } if...else  if...else if(MemberAge<18){ document.write("teen"); } else if(MemberAge>18){ document.write("adult"); } else{ document.write("just 18"); } Switch statement Ex1: switch(memcat){ case1: Fee=100; case2: Fee=150; case3: Fee=300;} Ex2: with break switch(memcat){ case1: Fee=100; break; case2: ...; } Ex3: no matching than default case switch(memcat){ case1: Fee=100; break; case2: ...; default: Fee:400; } Counting and Looping Executing a portion of code over and over again until an intermediaite condition accurs For statement Used as counter Syntax: for(start;condition;expression)statement Ex: var Number; for(Number=0;Number<=10;Number++) document.write("Num"+Number+"

JS-OOP

   < Beginner JS >< Function >< Variable > < Loop-If > < OOP > this member it represents the class itself it has direct access to all properties of its parent class function Hand(side,fingers,nails){ this.LeftOrRight =side; this.NbrOfFingers=fingers this.NailState=nails; } name of the class : Hand  properties :  (side,fingers,nails)  // properties of the function / of the class NailState  // property of the argument argument (value provided for each property) this.LeftOrRight =side; // argument of the function / of the class =nails;     // argument of the argument class: function Hand(side,fingers,nails){ this.LeftOrRight =side; this.NbrOfFingers=fingers this.NailState=nails; } This It has direct access to all properties of its parent class You must use it to create a class Before using a class you must declare it. var dogHand=newHand("Right",5,false,true); name of the object: dogHand name of the class: Hand arguments: "Right",5,false,t

JS-Function

 < Beginner JS >< Function >< Variable >< Loop-If >< OOP > Syntax of a function function name(){} Exemple function showAdress)_{ document.write("Hello"); } Function calling showAdress(); Function and local variables Variable declared in the body of a function ...{var custAdress}... Argument - > passing an argument This means: providing an argument to a function function circleArea(radius){ var areas; area=radius*radius*3.14; document.write("area is: ",area); } circleArea(20.75); function with more than one argument function rectangleArea(length,height){ var area; area=length*height*3.14; document.write("area: ",area); } var length,height; length=52.05; height=46.55; rectangleArea(length,height); Argument with different types function rectangleArea(length,height,shape){ ....} length=2; height=4; shape="rectangle"; rectangleArea(length,height,shape); Returning a value .... return area; } producing a value and making

JS-Variable

   < Beginner JS >< Function >< Variable > < Loop-If > < OOP > 1/ Variable <script> var FName=FirstName </script> Declaring a variable var FirstName var Adress,Phone,Email; You can declare: Natural numbers: Integer Decimal numbers: Double String: Text Assigning a value to a variable Salary=12 or var Salary=12 Display the value Document.write(Salary) Addition/Substraction/Multiplication/Division Document.write(125+40) Document.write(Salary+50) Negative Temp=-31 Function and local variables Variable declared in a body of a function ....{var custAdress}... Use Declared variable function showAdress(){ var custAdress custAdress="12 Hello" document.write(custAdress); } showAdress();

JS-beginner

 < Beginner JS >< Function >< Variable >< Loop-If >< OOP > 1/ General concepts Class It is a technique used to provide the criteria to define an object The list of items used to describe something Object It is the result of a description based on a class Method An action that an object can perform document.write("Jacques") document: Object write: method Jacques : Argument Properties It is the caracteristics used to describe an object. A property is created like a variable Method and their arguments It is a value that needs the method to work with to perform an action  protectRain(Reason) Argument  An item or value that a function needs.  It is provided between parenthesis Start and end <script> </script> or <script language="Javascript"> </script> Display string document.write("Jacques") 2/ Forms <form></form> Refering to a form document.CreditApplicationForm 2.1./ Text box <input type=&q

React-course notes

< React Course Notes >< ReactJS function > I) installation: https://www.freecodecamp.org/news/react-for-beginners-handbook/ run msdos in C;// run the command: - This creates the working folder npm create vite@5.1.0 my-alorya-app -- --template react II) to start vite.js run in msdos: cd my-alorya-app change folder with cd my-app - in msdos This installs the app in the folder: npm install Run Vite.js:  npm run dev With vite all is ready! -  Watch out :  There should be no errors in the installation (red text).  If there are any, you should correct them. creating project (without vite.js) I recommend you just use vite.js and not the following, I found them too comples, and I had many errors to correct. Run the code -  Run them if you do not use vite.js - if you use vite.js you don`t need them npm init -y install react libraries npm install react@^17.0.0 react-dom@^17.0.0 --save install babel npm install @babel/preset-env @babel/preset-react @babel/core @babel/plugin-proposal-c