Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Development-process Solve using only Javascript loops...
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Jeevan kumar
Solve using only Javascript loops...
5 Answer(s)      4 years and 2 months ago
Posted in : Development process


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.'


Advertisement
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


print("code sample");


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
Javascript loops
Javascript loops  Write a JavaScript code, - for guessing any number between 1 to 20. run the loop till you not get correct number. Use prompt...: <SCRIPT LANGUAGE="JavaScript"> var guess; var rno=Math.round(Math.random
Advertisements
Java reverse words in a string using only loops
Java 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
enabling and disabling a hyperlinks using javascript only
enabling and disabling a hyperlinks using javascript only  Hi! Anyone... using Java script only to achieve the problem descr... be enabled.And when the link is enabled only the page 2.jsp should be displayed
enabling and disabling a hyperlinks using javascript only
enabling and disabling a hyperlinks using javascript only  Hi! can... be enabled.And when the link is enabled only the page 2.jsp should be displayed...="javaScript" type="text/javascript" src="calendar.js"> function disableLink
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
displaying a calendar of only current month in jsp on webpage using javascript
displaying a calendar of only current month in jsp on webpage using javascript  how can we display a calendar of only current month in jsp on webpage using javascript
Use javascript loops..
Use javascript loops..  Write a Javascript code, so that numbers...(" "); for(var k=q; k>=1;k--){ document.write(" "); } for(var j=1;j<=i;j++){ document.write(" "); document.write(j); } document.write("<br>"); q
Using Nested loops
Using 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
pattern-using loops
pattern-using loops  Write a program that displays the following pattern ... (use nested loops) * ** * ** * ** *   the correct pattren
read string - using loops in Java
read 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 Function
JavaScript 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: JavaScript Loop
Loops
Loops  ??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
print 100 numbers using loops
print 100 numbers using loops  how to print from 1 to 100 using for loop ?   Hi Friend, You can use the following code: class Loop{ public static void main(String[] args){ for(int i=1;i<=100;i
print rectangle triangle with ?*? using loops
print 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
Solve it
Solve it  How to calculate the value which contains oparator and operand both using command line argument
loops
loops  I need the program output 55555 4444 333 22 1 like this by using for loop and if condition only
Loops
Loops  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
Loops
Loops  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
Loops
Loops  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
solve this
solve 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
loops
loops  how to get the sum of 10 number using a loop
loops
loops  how to use for loop and while loop in java?/ how to write a code using for or while loop
I need to output number diamond using nested for loops.
I need to output number diamond using nested for loops.  How to i output this using nested for loops 1 131 13531 1357531 135797531 1357531 13531 131 1
Java repeat string without using loops
Java 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: import
print a-z, A-Z with exact order using loops
print a-z, A-Z with exact order using loops  how to print from a-z, A-Z with exact order using for loop? Thanks for all concern
write program have product - using loops
write 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
Date object using JavaScript
Date object using JavaScript  What's the Date object using JavaScript
delete an entry using JavaScript
delete an entry using JavaScript  How to delete an entry using JavaScript
using for loop in javascript
using for loop in javascript  How to use for loop in JavaScript
Advertisements
 

 

 

DMCA.com