Solve using only Javascript loops...
Write a JavaScript code,
1) to find a number of unique letters in string. (Eg. if keyword is unique, Unique count will be '4')
2) so that numbers appear in following format,
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
for n=5. Input 'n' value from user.
3) to create a redirection script based on day of the week.
4) that reads the date of a day in one textbox, the month in a second textbox and the year in a third textbox. After submitting the form, it should display the complete date, including the correct extension on the day number ('st', 'nd', 'rd' or 'th'). Example : 2 April 1999 will produce: 'Today is 2nd of April, 1999.'
View Answers
October 21, 2010 at 5:31 PM
Hi Friend,
Try the following code:
1)
<script>
function code(n, digits, padChar) {
n = n.toString();
while (n.length < digits) {
n = padChar + n;
}
return n;
}
var str = window.prompt("Enter String");
var array = [];
var totalCount;
var count=0;
for(var i = 0; i < str.length; i++){
if(!array[str[i]]) {
array[str[i]] = 1;
} else {
array[str[i]] += 1;
}
}
sortedArray = [];
for(var i in array){
sortedArray.push(code(i.charCodeAt(0), 5, '0'));
}
sortedArray.sort();
for(i = 0; i < sortedArray.length; i++){
count++;
}
document.write("Number of unique letters are: "+count);
</script>
Thanks
October 21, 2010 at 5:42 PM
Hi Friend,
Try the following code:
4)
<script>
function number(value){
hunRem = value % 100;
tenRem = value % 10;
if (hunRem - tenRem == 10) {
return "th";
}
switch (tenRem) {
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
}
function display(){
var day=document.form.day.value;
var mon=document.form.month.value;
var year=document.form.year.value;
document.write("Today is "+day+number(day)+" of "+mon+", "+year);
}
</script>
<form name="form">
<table>
<tr><td>Enter Date of a day:</td><td><input type="text" name="day"></td></tr>
<tr><td>Enter month:</td><td><input type="text" name="month"></td></tr>
<tr><td>Enter year:</td><td><input type="text" name="year"></td></tr>
<tr><td><input type="button" onclick="display();" value="Submit"></td></tr>
</table>
</form>
Thanks
November 27, 2010 at 10:59 AM
November 27, 2010 at 10:59 AM
November 27, 2010 at 11:04 AM
Related Tutorials/Questions & Answers:
Solve using only Javascript loops...Solve using only Javascript loops... Write a
JavaScript code,
1) to find a number of unique letters in string. (Eg. if keyword is unique, Unique count will be '4')
2) so that numbers appear in following format,
1
1 2
Advertisements
enabling and disabling a hyperlinks using javascript onlyenabling and disabling a hyperlinks
using javascript only Hi! Anyone....
Question 2:
Is there a solution
using Java script
only to achieve the problem...
Question 2:
Is there a solution
using Java script
only to achieve the problem
Javascript loopsJavascript loops Write a
JavaScript code,
- for guessing any number between 1 to 20. run the loop till you not get
correct number. Use prompt... the following code:
<SCRIPT LANGUAGE="
JavaScript">
var guess;
var rno=Math.round
Java reverse words in a string using only loopsJava reverse words in a string
using only loops
In this tutorial, you will learn how to reverse words in a string without
using any inbuilt methods like split() etc, StringTokenizer functiom or any
extra ordinary function
Only loops Use javascript loops..Use
javascript loops.. Write a
Javascript code to create a redirection script based on day of the week
Use javascript loops..Use
javascript loops.. Write a
JavaScript code to find a number of unique letters in string. (Eg. if keyword is Tajmahal, Tajmahal count will be '5' , it
only takes these letters T,j,m,h,l , not taken the letter a because
Use javascript loops..Use
javascript loops.. Write a
Javascript code, so that numbers...--){
document.write(" ");
for(var k=
q; k>=1;k--){
document.write(" ");
}
for(var j=1;j<...;");
q++;
}
document.write("</center>");
</script>
ThanksADS
pattern-using loopspattern-
using loops Write a program that displays the following pattern ... (use nested
loops)
*
**
*
**
*
**
*
the correct pattren
Using Nested loopsUsing Nested loops How to use nested
loops in java when I want to print the 10 multiples of numbers 2 to 15(in multiplication table)
public class MultiplicationTable{
public static void main(String[] args) {
int
read string - using loops in Javaread string -
using loops in Java Write a program to read a string composed of an unknown number of words, then count the number of words in the string, and Display the longest and shortest words, with first letter Uppercase
JavaScript Loops FunctionJavaScript Loops Types:
In Java programming language a loop is a language... a function or method
calls itself).
JavaScript provides for, while, do-while, and foreach loop. Following examples will help you to learn
loops:ADS_TO_REPLACE_1
print 100 numbers using loopsprint 100 numbers
using loops how to print from 1 to 100
using for loop ?
Hi Friend,
You can use the following code:ADS_TO_REPLACE_1
class Loop{
public static void main(String[] args){
for(int i=1;i<
print rectangle triangle with ?*? using loopsprint rectangle triangle with ?*?
using loops *
* *
* * *
i want print like this.what is the code?
import java.lang.*;
class Traingles
{
public static void main(String args[])
{
for(int i=1;i<=5
LoopsLoops ï??
Using for
loops, Write a program to simulate
a clock countdown. The program prompts the
user to enter the number of seconds, displays
a message at every second, and terminates
when the time expires. Use method
loopsloops I need the program output 55555
4444
333
22
1 like this by
using for loop and if condition
only Java repeat string without using loopsJava repeat string without
using loops
In this section, you will learn how to repeat string without
using for
loops.
The given example accepts the number...
using while loop or any other control
statements.
Example:ADS_TO_REPLACE_1
LoopsLoops by
using drjava
q1.Write code that uses nested
loops to print the following patterns:
Pattern1:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
Pattern 2:
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
q2.Write code
write program have product - using loopswrite program have product -
using loops Write a program for a grocery that reads products data and determine and display the product that has the highest price and the average price. A product has three pieces of data: id (int
LoopsLoops Write code that uses nested
loops to print the following patterns:
Pattern1:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
Pattern 2:
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
LoopsLoops Write code that uses nested
loops to print the following patterns:
Pattern1:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
Pattern 2:
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
send mail using JavaScriptsend mail
using JavaScript How can we send mail
using JavaScript?
Hi friends,
You can not send email directly
using JavaScript.
But you can use
JavaScript to execute a client side email program send the email
using loopsloops how to get the sum of 10 number
using a loop
loopsloops how to use for loop and while loop in java?/ how to write a code
using for or while loop
How can we solve this puzzle using java ?How can we
solve this puzzle
using java ? Sachin likes sweets a lot. So, he goes to a market of sweets. There is a row of sweet stalls. Every sweet... of those stalls need to be contiguous. He also decided to buy
only 1 kg of sweets from
Solve itSolve it How to calculate the value which contains oparator and operand both
using command line argument
how to print HTML using javascript or Jqueryhow to print HTML
using javascript or Jquery is there any way to print a document(created
using Html and
javascript) without
using window.print... window.print but this required to enable pop-up and work
only in firefox. and I have also
solve thissolve this
Create a student class. The student object should have....
Retrieval and printing of data should be done both
using normal iteration and by
using enhanced for loop
Changing background color using JavaScriptChanging background color
using JavaScript Hi Sir
Is there any way to change the background color
using JavaScript ?
Please mention code with your answer.
Hello Friend
Pass the element & color in the given
javascript date validation using regexjavascript date validation
using regex Hi,
I want to validate the date
using javascript. Please help.
<html>
<head>
<title>Validating Date format</title>
<script type="text/
javascript">