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

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

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



print("code sample");
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.