Skip to content

how to change the value of variable after calling the function using tablesasjson?  #25625

@Alex1233456

Description

@Alex1233456

why the variable cannot be changed after calling the function?

this is my code:



const tabletojson = require('tabletojson');

var email ;

tabletojson.convertUrl(

    'https://myurl
    ,
    { stripHtmlFromCells: true },
    function(tablesAsJson) {


  email = tablesAsJson[2][7][1];
var result2 = tablesAsJson;
        console.log(result2);
        var Firstname;
        var lastname;
        Firstname = tablesAsJson[0][1][1]
        lastname = tablesAsJson[0][0][1]

        console.log("Hello Sir: "+Firstname + "  " +lastname + ".  your email is : " + email)

        console.log(email)// this prints the correct answer
    }
  );

> while trying to print email in out scope of the function 
its returning a blank text with console.log("the email is " + email);

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.wrong repoIssues that should be opened in another repository.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions