write a program to generte a harmonic series
1+1/2+1/3+1/4+1/5 upto 15 terms.
Answer Posted / upendar
<html>
<head>
<script type="text/javascript">
function hormonicSeries() {
for(var i=1;i<=15;i++) {
if(i == 1) {
var addSeries = 1/i;
} else {
for(var j=2; j<=15;j++) {
if(i == j) {
addSeries = addSeries +"+1/"+i ;
}
}
}
}
var series = addSeries;
document.write(series);
}
</script>
</head>
<body onload="hormonicSeries();">
</body>
</html>
| Is This Answer Correct ? | 4 Yes | 3 No |
Post New Answer View All Answers
How would you check if a variable is null/undefined?
Which built-in method combines the text of two strings and returns a new string?
What is the javascript function?
Can array in javascript be extended?
How to create function in JavaScript?
How to use one javascript function for multiple input fields?
How do you implement Ajax using hide() function in JQuery?
Where do I put javascript code in html?
Mention what is the disadvantage of using innerhtml in javascript?
How does javascript work?
What is a callback url?
What does two exclamation marks mean in javascript?
What is global variable in javascript?
What is the ‘Strict’ mode in JavaScript and how can it be enabled?
What does the isNaN() function?