Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions js/js_part4/assignment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Assignment part 4</title>
<script src="assignment.js"></script>
</head>
<body>
<h1>Assignment</h1>
</body>
</html>
14 changes: 14 additions & 0 deletions js/js_part4/assignment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//Question 1
let arr = [1,2,3,4,5,6,2,3]
let num = 2
let i = 0
while(i<arr.length){
if(arr[i]==num){
arr.splice(i,1);
}
i++;
}
console.log(arr)

//Question 2
let num1 = 6642120
12 changes: 12 additions & 0 deletions js/js_part4/practice.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Practice</title>
<script src="practice.js"></script>
</head>
<body>
<h1>Practice</h1>
</body>
</html>
11 changes: 11 additions & 0 deletions js/js_part4/practice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
console.log('List of even numbers upto 20');
for(let a=2; a<=20; a=a+2 ){
console.log(a);
}

console.log('Printing the 13s table using while loop:')
let b = 13
while(b<=130){
console.log(b);
b=b+13;
}
12 changes: 12 additions & 0 deletions js/js_part5/assignment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Assignment part 5</title>
<script src="assignment.js"> </script>
</head>
<body>
<h1 style="text-align: center;color: blueviolet;text-decoration: underline;">Assignment 5</h1>
</body>
</html>
31 changes: 31 additions & 0 deletions js/js_part5/assignment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Qsl . Create a program that generates a random number representing a dice roll.
// [The number should be between 1 and 6].

let max_rolled = 6
let dice = Math.random()
console.log("The number you got after rolling a dice: ",Math.floor(dice * max_rolled)+1)


// Qs2. Create an object representing a car that stores the following properties for the
// car: name, model, color.
// Print the car's name.

let car={
name:"Nissan Sunny",
model:"XL",
color:"silver"
}
console.log("car name is :",car.name)

// Qs3. Create an object Person with their name, age and city.
// Edit their city's original value to change it to "New York".
// Add a new property country and set it to the United States.

let person={
name:"helly",
age:"21",
city:"Godhra"
}
console.log("my object:",person.city="New York")
person.country="United States"
console.log("new profile",person)
12 changes: 12 additions & 0 deletions js/js_part6/assignment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Assignment part 6</title>
<script src="assignment.js"> </script>
</head>
<body>
<h1 style="text-align: center;color: blueviolet;text-decoration: underline;">Assignment 6</h1>
</body>
</html>
53 changes: 53 additions & 0 deletions js/js_part6/assignment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Qsl. Write a JavaScript function that returns array elements larger than a number.


let fungt = function(num){
let myArray = [5,6,9,2,0,20,6,33,1,3]
for (let i=0;i<=myArray.length;i++){
if(num<myArray[i]){
console.log(myArray[i]);
}
}

}
fungt(3)



// Qs2. Write a JavaScript function to extract unique characters from a string.
// Example: str = "abcdabcdefgggh"
// ans = "abcdefgh"

let myStr = "abcdabcdefgggh"
function dupfunc(myStr, newStr){
for(let i=0;i<myStr.length;i++){

}
}




// Qs3. Write a JavaScript function that accepts a list of country names as input and
// returns the longest country name as output.
// Example : country = ["Australia", "Germany", "lJnited States of America"]
// output : "United States of America"

let input = prompt("Enter a list of Country");
let array = input.split(",");

function longestString() {
return array.sort(function (a, b) {
return b.length - a.length;
})[0];
}
console.log(longestString());

// Qs4. Write a JavaScript function to count the number of vowels in a String argument.
let vowels = ['a','e','i','o','u'];
function checkVowels(vowels,myStr){

}

// Qs5. Write a JavaScript function to generate a random number within a range (start,
// end).
12 changes: 12 additions & 0 deletions js/js_part7/assignment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Assignment part 7</title>
<script src="assignment.js"> </script>
</head>
<body>
<h1 style="text-align: center;color: blueviolet;text-decoration: underline;">Assignment 7</h1>
</body>
</html>
39 changes: 39 additions & 0 deletions js/js_part7/assignment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Qsl . Write an arrow function named arrayAverage that accepts an array of numbers
// and returns the average of those numbers.

let arrayAverage = (arr) => {
let total = 0;
for (let number of arr){
total += number
}
return total / arr.length;

}
arr = [10,20,30,40]
console.log(arrayAverage(arr))



// Qs2. Write an arrow function named isEven() that takes a single number as argument
// and returns if it is even or not.


let isEven = (number) => {
if(number%2 == 0){
console.log("is even number")
}else{
console.log('Not even number')
}
}
let number = 51
isEven(number)


// Question 3
const object={
message:'Hello,World!',
logMessage(){
console.log(this.message);
}
};
setTimeout(object.logMessage, 1000);
7 changes: 7 additions & 0 deletions js/notes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
16_oct
- completed the javascript learning of part 3
17-oct
- completed the javascript learning of part 4
- learn the for loops and while loops also nested loops
21_oct
- completed learning javascript part 5
- learn some randome and maths functions and how to use it.
- also learned the objects and arrays