What is the error here? (Beginner BTW)

This is my first time using VSC, so I am new to VSC, and this is the first time I am using it. I am using a tutorial and when I run my program (on Windows Script Host) , it gives me a error even though the code is not wrong. The error I got is:

Script: E:\code.projects\JSTUT.js
Line: 4
Char: 9
Error: Expected ‘;’
Code: 800A03EC
Source: Microsoft JScript compilation error


// Pi = 4/1 - 4/3 + 4/5 - 4/7...

function calcPI(iterations){
    let pi = 0, divisor = 1;
    for(i = 0; i <= iterations; i++){
        pi = pi + (4/divisor) - (4/
        (divisor + 2));
        divisor += 4;
    .value = pi.toFixed(10);

let fibLib = [];
function getFibList(howMany){
   for(i = 0; i < howMany; i++){
       fibList[i] = fib(i);
   .value = fibList.join(", ");

function fib(whichNum){
    let num1 = 1, num2 = 0, temp, 
    i = 0;
    while(i < whichNum){
        temp = num1;
        num1 = num1 + num2;
        num2 = temp;
    return num2;



Let me know if I should give more information.
Thanks in advance, and have a great day!

You forgot a semicolon somewhere. Btw, are you running this in the browser right?


I believe the error comes from your for loops. You’re using i = 0 which throws an i is undefined error, because you haven’t declared that variable yet.

You declare a variable with var, let, or const. I’d use let, here. :slight_smile:

It is still giving the same error. I looked it up online and it said it has to do with running it with Internet Explorer. I don’t understand this issue.

I have checked but I can’t find a missed semicolon error anywhere :slightly_frowning_face:

And yes I am running this in the browser.

I have checked but I can’t find a missed semicolon error anywhere :slightly_frowning_face:

And yes I am running this in the browser.

Is this your whole code?

Just ran the code, and I don’t seem to get any errors.

Could you provide html file?

Someone could maybe take the tutorial code and then his code and run git diff to see differences. Or I think git bisect

I would run it, but don’t have the time.

this seems to be line 4
character 9 is after the 0
maybe you can’t put many variable declarations on the same line

Here you go.


<!doctype html>
<html lang="en">
      <meta charset="utf-8">
      <meta name="viewport" content="width = device-width,
      initial-scale = 1">
      <title>JavaScript Tutorial</title>
      <link rel="stylesheet" href="https://
      <script src="https://stackpath.bootstrapcdn.com/bootstrap/
      <link rel="stylesheet" type="text/css" 
      <script src="JSTUT.js"></script>

    <div class="container">
        <div class="jumbotron">
            <h3>MadLib Generator</h3>
            <form class="form-inline">
                <input type="text" class="form-control"
                id="i0" value="Person"/>
                <input type="text" class="form-control"
                id="i1" value="Noun"/>
                <input type="text" class="form-control"
                id="i2" value="Verb"/>
                <input type="text" class="form-control"
                id="i3" value="Verb"/>
                <input type="text" class="form-control"
                id="i4" value="Verb"/>
                <input type="text" class="form-control"
                id="i5" value="Verb"/>
                <input type="text" class="form-control"
                id="i6" value="Plural Verb"/>
                <input type="text" class="form-control"
                id="i7" value="Verb"/>
                <input type="text" class="form-control"
                id="i8" value="Adjective"/>
                <input type="text" class="form-control"
                id="i9" value="Noun"/>
                <input type="text" class="form-control"
                id="i10" value="Event"/>
                <input type="text" class="form-control"
                id="i11" value="Noun"/>
                <input type="text" class="form-control"
                id="i12" value="Body Part"/>
                <input type="text" class="form-control"
                id="i13" value="Noun"/>
            <button type="submit" class="btn-lg" 
            <button type="submit" class="btn-lg" 
            onClick="calcPI(100000000)">Get PI</button>
            <button type="submit" class="btn-lg" 
            onClick="getFibList(20)">Get Fibs</button>
            <button type="submit" class="btn-lg" 
            <div class="input-group">
                <div class="input-group-prepend">
                    <span class="input-group-text">Output</span>
                <textarea id="output1" rows="18" 


    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" 
    <script src="https://cdnjs.cloudflare.com/ajax/

Is this what you wanted me to provide?

I have tried that before, but it doesn’t make a difference unfortunately :slightly_frowning_face: .

you mean you still get the same error?
has it maybe changed the line to which it refers to or you get the same exact error if you write as below?

let pi = 0;
let divisor = 1;

It is the exact same error if I write it both ways.


When you say you get an error from running the code, how are you running it?

I run it on a browser. Specifically Google Chrome.

Interesting - the error you posted reads like the type of error you get from trying to run a .js file directly from the windows file explorer, so I had to double check. :slight_smile:

Unfortunately, that leaves me at a loss for the error cause again.

Good news! So I found a problem with my code, it did not fix the file but when I run the whole program the JavaScript works! However, my Fib list button is not working. I will have to check it out later.

1 Like

I figured out the problem! The error is there but the whole program works now! It was just that I accidentally typed “fibLib” instead of “fibList” on line 14! Thank you everyone for helping me! I really appreciate it! I am glad it is solved now!

Line 14 (Corrected) :

let fibList = [];
1 Like