0% found this document useful (0 votes)
7 views

Important program in Javascript

Great books

Uploaded by

Vicky Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Important program in Javascript

Great books

Uploaded by

Vicky Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Important program in Javascript

Find factorial of a number in JavaScript?

<!DOCTYPE html>
<html>
<head>
</head>
<body style = "text-align: center; font-size: 20px;">
<h1> Welcome to the javaTpoint.com </h1>
Enter a number: <input id = "num">
<br><br>
<button onclick = "fact()"> Factorial </button>
<p id = "res"></p>
<script>
function fact(){
var i, num, f;
f = 1;
num = document.getElementById("num").value;
for(i = 1; i <= num; i++)
{
ff = f * i;
}
ii = i - 1;
document.getElementById("res").innerHTML = "The factorial of the number " + i + " is: " + f
;
}
</script>
</body>
</html>

Find Prime Number in JavaScript?


// Function to check prime number

function checkPrime(num) {
let i, flag = true;
for (i = 2; i <= num - 1; i++) {
if (num % i == 0) {
flag = false;
break;
}
}
if (flag == true)
console.log(num + " is prime");
else
console.log(num + " is not prime");
}
checkPrime(4);
checkPrime(5);

Find Number is even or odd in JavaScript?

/ program to check if the number is even or odd


// take input from the user
const number = prompt("Enter a number: ");

//check if the number is even


if(number % 2 == 0) {
console.log("The number is even.");
}

// if the number is odd


else {
console.log("The number is odd.");
}

Check Palindrome number and string by accepting the number


through prompt box.

<html>
<head> <title> JavaScript Palindrome </title>
</head>
<body>

<!-- Use JavaScript programming code to validate the Palindrome numbers or strings. -->
<script>

function validatePalin(str) {

// get the total length of the words


const len = string.length;

// Use for loop to divide the words into 2 half


for (let i = 0; i < len / 2; i++) {
// validate the first and last characters are same
if (string[i] !== string[len - 1 - i]) {
alert( 'It is not a palindrome');
}
}
alert( 'It is a palindrome');
}

// accept the string or number from the prompt


const string = prompt('Enter a string or number: ');

const value = validatePalin(string);

console.log(value);
</script>
</body>
</html>

JavaScript Program to find the Sum of n natural numbers.


<html>
<head>
<title>JavaScript program to find the Sum of n natural numbers</title>
</head>
<body>
<table>
<tr>
<td> <input type="text" name="a" id="first" placeholder="Enter a number"/> </td>
</tr>
<tr>
<td> <button onclick="sum ()">Submit</button></td>
</tr>
</table>
<div id="num"></div>
</body>

<script type="text/javascript">
function sum()
{
var n,i, sum = 0;
n = parseInt(document.getElementById ("first").value);
for (i = 1; i <= n; i++)
{
sum = sum+i;
}
document.getElementById ("num").innerHTML="Sum of "+n+ " natural numbers is
:"+sum;
}
</script>
</html>

Identifying small objects like street signs presents a significant challenge, particularly in dynamic
environments with varying lighting and obstructions. This paper focuses on developing an efficient
and reliable method for street sign identification. A novel approach is proposed, leveraging
convolutional neural networks (CNNs) augmented with simplified Gabor feature maps. This
combination enhances feature extraction and enables precise classification, maintaining a balance
between accuracy and computational efficiency.The system is trained on a comprehensive dataset
of over 50,000 realistic street sign images spanning 43 distinct classes. This dataset includes
variations in distance, lighting conditions, occlusions, and rotations, ensuring the model's
robustness and generalizability across diverse real-world scenarios. During the detection stage,
parameters from the Gabor feature maps are utilized to classify street signs, enhancing accuracy
while maintaining computational efficiency. Experimental results demonstrate that the system
achieves an impressive 97% accuracy under favorable daylight conditions, confirming its
effectiveness in recognizing a wide variety of street signs. However, performance under low-light
or nighttime conditions drops to 74%, indicating room for improvement in challenging
environments. Future work will aim to enhance nighttime accuracy, making the system suitable
for deployment in autonomous vehicles and intelligent traffic management systems.

You might also like