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

 
 


Jeevan kumar
Solve using only Javascript loops...
5 Answer(s)      2 years and 7 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.'

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 Pages:
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
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
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
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
Solve it
Solve it  How to calculate the value which contains oparator and operand both using command line argument
loops
loops  how to use for loop and while loop in java?/ how to write a code using for or while loop
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
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
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
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
plz solve my query?
plz solve my query?  how to remove all the options from select control in html using java script?   JavaScript remove all items <html> <script language="javascript" > function removeAllItems(selectbox
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 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.   Hi Friend, Try
Loops
3.10. Loops Loops are the essential part of the program that have.... More than one loops can be used several times in a script. Loops makes easy... instructed for repetition of the code. PHP Loops In PHP, like other programming
Digit Only text field
Digit Only text field  How should we accept digits only in a textbox? (using JSTL only, without Javascript
solve this pbm
solve this pbm  its not working the code for databae access using servlets
pattern-using loops
pattern-using loops  Write a program that displays the following pattern ... (use nested loops) * ** * ** * ** *   the correct pattren
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
ajax code please help to solve this........
ajax code please help to solve this.  in this i am trying to get data from datbase and put it in combo box and then display it down using table.../javascript"> var ob; function fun(str) { try
JavaScript - JavaScript Tutorial
with the Java Scripting language. You will learn the benefits of using JavaScript... example to use while, do-while and switch loops in JavaScript  ... will learn how to create popup window using JavaScript.   Form
nested for loops
. This is my first time using java and my first time programming, but I am guessing..."); } } } }   Close your loops before going
solve this problem
solve this problem  I typed this program and compiled.The program is compiled but when i eneterd url in tomcat server. Its not giving error but only blank page is coming the text is not displaying and row is also inserted
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
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
For Loops
For loop is used to run the code in the block in the specified number of times. It is pre-directed and can write using parameters.  Syntax for (init; condition; increment)   {   code to be executed;  
Loops - Introduction
will introduce you with the Loops in Java. Loops are very useful in programming... Many loops consist of three operations surrounding the body: (1) initialization... must put the statements inside braces. If there is only one statement
JavaScript - JavaScript Tutorial
JavaScript objects and the syntax of the language like statements, conditionals, loops... of using JavaScript in your programming.    Fundamentals... loops in JavaScript   Functions in JavaScript
JavaScript - JavaScript Tutorial
JavaScript objects and the syntax of the language like statements, conditionals, loops... of using JavaScript in your programming.    Fundamentals... loops in JavaScript   Functions in JavaScript
Arrays, loops and string handling
Arrays, loops and string handling  How would i go about in creating a program to mark and grade a set of multiple choice test results... correct answers using JOptionPane dialog box and store the entire answer as on string
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
java loops - Java Beginners
a program to reverse a string using another array and without using another array
java loops - Java Beginners
java loops  Q1-sum the series 2/9-5/13+8/17..... Q2 print first n odd numbers in descending order? Q3 program to input digits and write in words with out using any type of in built function and array program to print truth
help me to solve this question...
help me to solve this question...  Given below is a class definition for Book. Type and compile the class, and answer the following questions... and then create an array name myLibrary of type Book with size n. Using loop, create n
help me to solve this problem..
help me to solve this problem..  Given below is a class definition for Book. Type and compile the class, and answer the following questions: class... and then create an array name myLibrary of type Book with size n. Using loop, create n
Solve my code
Solve my code  import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.io.*; public class ChangeDetails extends... is the mistake in this code! This is working only one record doesn't work
solve my question shortly
solve my question shortly  <html> <head> <script>...)){ alert('It should contain numbers [0-9] only!'); document.getElementById...('It should contain numbers [0-9] only!'); return false
solve it - Java Beginners
solve it  Hi friend, I want to use switch case in jsp please let me know how to call page in jsp using include tag i want call this file using include tag please help me use switch statement in jsp
Solve this problem plzzz
Solve this problem plzzz  Prashant.jsp (this is my JSP file) <HTML> <HEAD> <TITLE>Login using jsp <BODY>... kindly help me and check all those files and solve my problem as soon as possible
I couldn't solve it
I couldn't solve it  *A customer who wants to apply for getting a car... is specialized in only one brand. Thus, according to the brand of the car... of each customer after the receiving his/her license. You are only allowed to use
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
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
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.