Skip to content

Commit

Permalink
function
Browse files Browse the repository at this point in the history
  • Loading branch information
ARQUM21 committed May 1, 2024
1 parent 41a85e7 commit d5d46c8
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 41 deletions.
166 changes: 128 additions & 38 deletions Assignment/app.js
Original file line number Diff line number Diff line change
@@ -1,81 +1,171 @@
//Q1

var username = "Arqum";
// var username = "Arqum";

console.log(username.length);
// console.log(username.length);

//Q2

var username = "arqum";
result = username.toUpperCase();
console.log(result);
// var username = "arqum";
// result = username.toUpperCase();
// console.log(result);

//Q3

var username = "ARQUM";
result = username.toLowerCase();
console.log(result);
// var username = "ARQUM";
// result = username.toLowerCase();
// console.log(result);

//Q4

var a = "hello my name is Arqum";
console.log(a.charAt(6));
// var a = "hello my name is Arqum";
// console.log(a.charAt(6));


//Q5

var username = prompt ("Enter a number")
// var username = prompt ("Enter a number")

result = username.substring(0,4);
// result = username.substring(0,4);

console.log(result);
// console.log(result);


//Q6

var text = "arqum"
result = text[0].toUpperCase();
console.log(result);
// var text = "arqum"
// result = text[0].toUpperCase();
// console.log(result);

//Q7


var email = " marqum029@gmail.com ";
console.log(email+ "---> " + email.length);
console.log("trim--> "+ email + "---> " + email.trim().length);
// var email = " marqum029@gmail.com ";
// console.log(email+ "---> " + email.length);
// console.log("trim--> "+ email + "---> " + email.trim().length);

//Q8

var character = prompt("Enter a character:");
//Q8

const vowels = ['a', 'e', 'i', 'o', 'u'];
// var username = "arqum"

if (vowels.includes(character)){
console.log("Vowel");
}
else if ("[a-zA-Z]"){
console.log("Consonant");
}
// result = username.substring(0,4);

// console.log(result);

//Q9

var username = "arqum"
// var a ="arqum";

result = username.substring(0,4);
// result = a.length;

console.log(result);
// console.log(result);

//Q10

var a ="arqum";

result = a.length;
// var text = "Arqum got first position in class.";
// text = text.replace('Arqum got first position in class.' , 'sentence is removed');
// console.log(text);

console.log(result);

//Q11

var text = "Arqum got first position in class.";
text = text.replace('Arqum got first position in class.' , 'sentence is removed');
console.log(text);
// var sentence = "javascript is wonderful programming languuage";

// var vowelcount = 0;
// var constcount = 0;

// for(var i = 0; i < sentence.length; i++ ){
// if(sentence[i].toLowerCase() === "a" || sentence[i].toLowerCase === "e" || sentence.toLowerCase === "i" || sentence.toLowerCase === "o" || sentence.toLowerCase === "u"){
// vowelcount ++;
// }
// else if (sentence[i] !== " "){
// constcount ++;

// }
// }

// var vowels = ["a","e", "i", "o", "u"];

// for (let i = 0 ; i < sentence.length ; i++){
// var vowelfound = false;

// for (let j = 0; j < sentence.length; j++){
// if (sentence[i].toLowerCase() === vowels[j]){
// vowelfound = true;

// break;
// }
// }

// if (vowelfound) vowelcount ++ ;
// if (!vowelfound && sentence[i] !== " " ) constcount++;
// }

// console.log ("vowelscount->", vowelcount);
// console.log ("constcont->", constcount);



//Q12 Count the number of letter a used in sentence.

// var sentence = "javascript is wonderful programming languuage";
// var count = 0

// for (var i = 0 ; i < sentence.length ; i++){
// if (sentence.charAt(i).toLowerCase() === "A") count++;
// }

// console.log("Number A in this sentence are", count);


//Q13 Capitilize first letter of each word.

// var userName = "Muhammad Arqum Tariq"
// var arr = userName.split("");
// console.log(userName);
// console.log(arr);

// for (var i = 0; i < arr.length ; i++){
// var word = arr[i];
// arr[i] = word[0].toUpperCase() + word.slice(1);
// }

// console.log(arr);
// var updated = arr.join(" ");
// console.log(updated);

//Q14 Password must include 1 capital letter , 1 number , min length should be 8.

// var upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// var special = "!_@$%";

// var password = prompt ("Enter password min length 8, 1 uppper case, 1 Number ");

// console.log(password);




var box = document.getElementById("box");
console.log(box.style);

function changered(){
box.style.background = "red";
}

function changeorange(){
box.style.background = "orange";
}

function changeblue(){
box.style.background = "blue";
}

function changeblack(){
box.style.background = "black";
}

function changeyellow(){
box.style.background = "yellow";
}
25 changes: 25 additions & 0 deletions Assignment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,32 @@
<body>

<h1>Assignment</h1>
<style>
.box{
background-color: aqua;
height: 300px;
width: 700px;
margin: 0px auto;
cursor: pointer;
}
.colorbox{
height: 60px;
width: 60px;
margin: 10px;
cursor: pointer;
}
</style>

<div class="box" id = "box"></div>

<div style="display: flex; justify-content: center; align-items: center; margin: 0px auto;">
<div onmouseover="changered()" class="colorbox" style="background-color: red;"></div>
<div onmouseover="changeorange()" class="colorbox" style="background-color: orange;"></div>
<div onmouseover="changeblue()" class="colorbox" style="background-color: blue;"></div>
<div onmouseover="changeblack()" class="colorbox" style="background-color: black;" ></div>
<div onmouseover="changeyellow()" class="colorbox" style="background-color: yellow;"></div>
</div>

<script src="app.js"></script>
</body>
</html>
54 changes: 51 additions & 3 deletions Changing Case/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,54 @@
// console.log(sentence.lastIndexOf("document"));


//Q7

// var sentence = "javascript is wonderful programming languuage";

// var vowelcount = 0;
// var constcount = 0;

// for(var i = 0; i < sentence.length; i++ ){
// if(sentence[i].toLowerCase() === "a" || sentence[i].toLowerCase === "e" || sentence.toLowerCase === "i" || sentence.toLowerCase === "o" || sentence.toLowerCase === "u"){
// vowelcount ++;
// }
// else if (sentence[i] !== " "){
// constcount ++;

// }
// }

// var vowels = ["a","e", "i", "o", "u"];

// for (let i = 0 ; i < sentence.length ; i++){
// var vowelfound = false;

// for (let j = 0; j < sentence.length; j++){
// if (sentence[i].toLowerCase() === vowels[j]){
// vowelfound = true;

// break;
// }
// }

// if (vowelfound) vowelcount ++ ;
// if (!vowelfound && sentence[i] !== " " ) constcount++;
// }

// console.log ("vowelscount->", vowelcount);
// console.log ("constcont->", constcount);


//Q8 Count the number of letter a used in sentence.

var sentence = "javascript is wonderful programming languuage";
var count = 0
for (var i = 0 ; i < sentence.length ; i++){
if (sentence.charAt(i).toLowerCase() === "A") count++;
}
console.log("Number A in this sentence are", count);


//charAt

// var username = "Arqum";
Expand All @@ -89,6 +137,6 @@

//trim

var email = " marqum029@gmail.com ";
console.log(email+ "---> " + email.length);
console.log("trim--> "+ email + "---> " + email.trim().length);
// var email = " marqum029@gmail.com ";
// console.log(email+ "---> " + email.length);
// console.log("trim--> "+ email + "---> " + email.trim().length);

0 comments on commit d5d46c8

Please sign in to comment.