Page 386 - Web Applications (803) Class 11
P. 386

29.  Assume a string “hi how are you”. Write JavaScript code to display

                    a. The length of the string
                    b. All characters between positions 5 and 12. (Both inclusive)

               Ans.  <html>
                   <body text=”blue”>
                   <script>
                   var str1=”hi how are you”;

                   document.write(“Length of string: “+str1.length);
                   document.write(“<br>Characters 5-12 are: “+str1.substring(5,13));
                   </script></body>
                   </html>
                   Output:







                384   Touchpad Web Applications-XI
   381   382   383   384   385   386   387   388   389   390   391