0% found this document useful (0 votes)
1 views3 pages

Java Script

The document provides an overview of JavaScript programming concepts, including variables, strings, functions, flow control, and loops. It explains variable declaration and assignment, string methods, comparison and logical operations, and demonstrates various loop implementations. Additionally, it includes examples of manipulating strings and calculating factorials using prompts and console logging.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views3 pages

Java Script

The document provides an overview of JavaScript programming concepts, including variables, strings, functions, flow control, and loops. It explains variable declaration and assignment, string methods, comparison and logical operations, and demonstrates various loop implementations. Additionally, it includes examples of manipulating strings and calculating factorials using prompts and console logging.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

JAVA SCIPT\

progrmming are set of insrtuction


ECMA is a principle thatgiude JS follows
1.Variable:(is like a file or folder where we store something inside) variable is
use to store information sothat you can use it to manipulate it later on.
In boot key word to cearte a variable(LET) (=== means to compare) let NAME= x let
allow to update the variable (another function that works like let is CONST)
Variable declearation(let tempearture;) and variable assignaton(let temperature =
40)
to see what you have done (console.log (name oft the variable))
------STRINGS METHOD(" ")----------
2.Strings:(a string start with a double quote and end with a double quote) string
should be wrapped in a double quote

3. FUNCTION:() PIE.AI .............. index starts form ZERO

4. CHARACTER (Sring CharAt):(The CharAt() method return the character at a


specifiied index(position) in a string)
5. String concat():(The concat method of string value concatenates the string
arguments to this string and return a new sring) used insteatd of ()
6. indexOf(string method) (it searches for something),(and the position)
7. STRING REPLACE:(what you want to relace and the replacement in the parentences)
8. String repeeat
9.Startswith uses index()
10.Endswith uses length()
11.typeof()
12.charCodeAt()
13.Flow control(conditional statement if this then that)
14.PROMPT()

------FLOW CONTROL (IF ELSE


STATEMENT.)-------
COMPARISON OPERATION
1.= : For Assignation.(let name = "504")
2.== :For Comparison of equality.(console.log(***** == 504)),(loose equality)
3.=== : For compating data type.(console.log(***** ==== 504)),(Strict equality)
4.!= : NOT EQUAL TO (for comparing data type)
5.!==
6.>
7.<
8.>=
9.<=
LOGICAL OPERATION
1.&&
2.||
3.!

LOOPS
For Loops

let factorial = prompt("input your number")


let output = 1
for(let i = factorial; i >= 1; i--){
output = output * i
}
console.log(output)

let sentence = prompt("Input your sentence");


let capitalizedSentence = '';
let capitalizeNext = true;

for (let i = 0; i < sentence.length; i++) {


let str = sentence.charAt(i);

if (str === ' ') {


capitalizedSentence += str;
capitalizeNext = true;
} else if (capitalizeNext) {
capitalizedSentence += str.toUpperCase();
capitalizeNext = false;
} else {
capitalizedSentence += str;
}
}

console.log(capitalizedSentence);

let inputString = prompt("Input a string");


let reversedString = '';
let length = inputString.length;

for (let i = length - 1; i >= 0; i--) {


reversedString = reversedString + inputString.charAt(i);
}

console.log(reversedString);

let inputString = prompt("Input a string");


let cleanedString = '';
let length = inputString.length;

for (let i = 0; i < length; i++) {


let str = inputString.charAt(i);
let isDuplicate = false;
for (let j = 0; j < cleanedString.length; j++) {
if (str === cleanedString.charAt(j)) {
isDuplicate = true;
break;
}
}

if (!isDuplicate) {
cleanedString = cleanedString+ str;
}
}

console.log(cleanedString);

You might also like