javascript
Brief description  about Online courses   join in Online courses
View Thangam  Nayagi 's Profile

javascript loop assignment

hi sir,

i'm doing my loop assignment and when i try to execute the following code i get the error msg " Expected ; at line 3"

<script type="text/javascript">
function guesser(){
var p=prompt("Enter the Number");
for ( i=1 i<=20 i ){
if ( i = p){
alert( "The Number is " i);
}}}
</script>

i tried taking of the ; but still get the same pbm, hope you can help me sort out the pbm in this code
Asked by Thangam Nayagi | Apr 25, 2011 |  Reply now
Replies (2)
View thangam nayagi 's Profile
Thanks sir, found your reply useful
Apr 25, 2011
View teacher siliconindia 's Profile
use it ;
modified this code ;

<script type="text/javascript">
function guesser(){
var i=1;
var p=prompt("Enter the Number");
for ( i=1; i<=p.length; i++ ){

alert( "The Number is " +i);
}}
</script>
Apr 25, 2011