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
15 changes: 15 additions & 0 deletions assignment-07-googledrive-upload/1-prime-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Function to check if a number is prime
function isPrime(num) {
if (num < 2) return false; // Numbers less than 2 are not prime

for (let i = 2; i <= Math.sqrt(num); i++) { // Loop from 2 to square root of num
if (num % i === 0) {
return false; // If divisible, it's not a prime number
}
}
return true; // If no divisor found, it's prime
}

// Example usage
const number = 17; // Change this number to test other values
console.log(`${number} is ${isPrime(number) ? 'a prime' : 'not a prime'} number.`);
8 changes: 8 additions & 0 deletions assignment-07-googledrive-upload/2-function-demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Function definition
function addNumbers(a, b) {
return a + b; // Returns the sum of a and b
}

// Function call
const sum = addNumbers(5, 10);
console.log(`Sum: ${sum}`); // Output the sum
33 changes: 33 additions & 0 deletions assignment-07-googledrive-upload/3-css-demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Example</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
text-align: center;
}
.container {
margin-top: 50px;
padding: 20px;
background: white;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
display: inline-block;
}
h1 {
color: #333;
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to CSS Styling</h1>
<p>This is an example of inline CSS styling.</p>
</div>
</body>
</html>

23 changes: 23 additions & 0 deletions assignment-07-googledrive-upload/4-operators-data-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Arithmetic Operators
let a = 10, b = 5;
console.log(`Addition: ${a + b}`);
console.log(`Subtraction: ${a - b}`);
console.log(`Multiplication: ${a * b}`);
console.log(`Division: ${a / b}`);

// Comparison Operators
console.log(`Equal: ${a == b}`);
console.log(`Not Equal: ${a != b}`);
console.log(`Greater than: ${a > b}`);

// Logical Operators
console.log(`AND: ${true && false}`);
console.log(`OR: ${true || false}`);
console.log(`NOT: ${!true}`);

// Data Types
let str = "Hello"; // String
var boolean = true; // Boolean
let num = 42; // Number
let obj = { name: "John" }; // Object
console.log(`String: ${str}, Boolean: ${boolean}, Number: ${num}, Object: ${JSON.stringify(obj)}`);
16 changes: 16 additions & 0 deletions assignment-07-googledrive-upload/5-temperature-conversion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Function to convert Celsius to Fahrenheit
function celsiusToFahrenheit(celsius) {
return (celsius * 9/5) + 32;
}

// Function to convert Fahrenheit to Celsius
function fahrenheitToCelsius(fahrenheit) {
return (fahrenheit - 32) * 5/9;
}

// Example usage
let celsius = 25;
console.log(`${celsius}°C = ${celsiusToFahrenheit(celsius)}°F`);

let fahrenheit = 77;
console.log(`${fahrenheit}°F = ${fahrenheitToCelsius(fahrenheit)}°C`);
27 changes: 27 additions & 0 deletions assignment-07-googledrive-upload/6-registration-form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
</head>
<body>
<h2>Registration Form</h2>
<form action="#" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br><br>

<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>

<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>

<label for="gender">Gender:</label>
<select id="gender" name="gender">
<option value="male">Male</option>
<option value="female">Female</option>
</select><br><br>

<input type="submit" value="Register">
</form>
</body>
</html>
26 changes: 26 additions & 0 deletions assignment-07-googledrive-upload/7-table-example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>Table Example</title>
</head>
<body>
<h2>Sample Table</h2>
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
<td>New York</td>
</tr>
<tr>
<td>Jane</td>
<td>30</td>
<td>Los Angeles</td>
</tr>
</table>
</body>
</html>
19 changes: 19 additions & 0 deletions assignment-07-googledrive-upload/8-perfect-numbers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Function to check if a number is perfect
function isPerfect(num) {
let sum = 0;
for (let i = 1; i < num; i++) {
if (num % i === 0) {
sum += i;
}
}
return sum === num;
}

// Function to find indices of perfect numbers in an array
function findPerfectIndices(arr) {
return arr.map((num, index) => isPerfect(num) ? index : -1).filter(index => index !== -1);
}

// Example usage
let numbers = [6, 28, 12, 496, 8128, 7];
console.log(`Indices of perfect numbers: ${findPerfectIndices(numbers)}`);
26 changes: 26 additions & 0 deletions assignment-07-googledrive-upload/9-validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Function to validate email
function validateEmail(email) {
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return regex.test(email);
}

// Function to validate phone number (10-digit format)
function validatePhone(phone) {
const regex = /^\d{10}$/;
return regex.test(phone);
}

// Function to validate password (at least 8 characters, one number, one special character)
function validatePassword(password) {
const regex = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
return regex.test(password);
}

// Example usage
const email = "test@example.com";
const phone = "1234567890";
const password = "Test@1234";

console.log(`Email valid: ${validateEmail(email)}`);
console.log(`Phone valid: ${validatePhone(phone)}`);
console.log(`Password valid: ${validatePassword(password)}`);
Binary file not shown.