To Concatenate Strings, Simply Use A + Sign With Two Variables of Strings

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

REVIEWER-ICT To concatenate strings, simply use a + sign with two

variables of strings.
JAVASCRIPT SELF LEARNING
++ increment operator
Javascript - client side scripting language when a user
goes to a website, the web server will send an HTML file Var num = 6
back to the user and it will include the Javascript code. Document.write(num++) // this will
still output 6
It uses browser then execute code when it is processing // it will still be read as num
the page. Document.write(num) // this time it
will increment na
In contrast with server side it is a language that will not
send the code to the user but just shows the output of
Another example:
the code.
Var num = 7
What is the difference of Javascript from Java?
var next = ++num;
document.write(next)
Javascript has many uses including form validation,
effects on a webpage and interactive content. strings have some internal properties like length of the
string
Html or htm file extension is good

You put javascript in a <script> tag you can get the length by variablename.length
To print something you could use ex.
Document.write
Var abc = “ABCDEFG”
Var result = abc.length
We start with variables.
Variable – has name and a value OUTPUT:
7
Var keyword
You can also get the subelements of the whole string by
In other languages, when you declare a variable, you this syntax
need to declare the variable type. Ex. Int var. //example – we only want to get DE
Var abc = “ABCDEFG”
But in javascript, you don’t do that. Var result = abc.substring(3,5)

You just declare var keyword. OUTPUT:


DE
Ex.
Var myvariable = false; If we set the starting point of the range as 0, will output
Var myvariable = 5; to ABCDE
Var my variable = “asdfa” Note. 0 element – A
But still the count for the last range E = 5

To put comments use // ARRAYS - holds many values


Commonly used in for loops

CONCATENATION
To declare an array

Var a = new Array(7);

Or much simpler, use bracket instead

Var a = [“dog”, “cat”]

DEFINING FUNCTIONS

If you have functions that you want to reuse.

You can call functions as many times as you want

<script>
function methodName() {
document.write(“<br>”);
methodName(“Mary”);
}
</script>

Possible: you can call the methondName() over and over


again. You can call it within another tag
Ex. You placed it inside the head tag

You can recall the function inside the body tag

Alert() method – a methd that gives you a dialog box

LOOPS

Review “for” loop

For(declaration;condition;increment)

You might also like