How do I set text from variable into a another variable?



  • I have JS code . How to set the contents (text) of the [[LIST_WITH_FILE_CONTENT]] variable
    in the variable

    let list = 
    

    instead of this text

    When I consider every thing that grows
    Holds in perfection but a little moment,
    Vaunt in their youthful sap, at height decrease,
    And wear their brave state out of memory
    

    In this JS-code:

    let list = `When I consider every thing that grows
    Holds in perfection but a little moment,
    Vaunt in their youthful sap, at height decrease,
    And wear their brave state out of memory`.split('\n');
     
    for(let i = 0, temp = []; i < list.length; i++) {
        if(temp.includes(list[i].toLowerCase())) {
            list.splice(i, 1);
            i--;
        } else {
            temp.push(list[i].toLowerCase());
        }
    }
     
    console.log(list);
    [[LIST_WITH_FILE_CONTENT]]=list;
    

    I tried putting it that way, but I get the error TypeError: _BAS_VARIABLES.LIST_WITH_FILE_CONTENT.filter.split is not a function
    Here's how, but I get an error:

    let list = [[LIST_WITH_FILE_CONTENT]].split('\n');
     
    for(let i = 0, temp = []; i < list.length; i++) {
        if(temp.includes(list[i].toLowerCase())) {
            list.splice(i, 1);
            i--;
        } else {
            temp.push(list[i].toLowerCase());
        }
    }
     
    console.log(list);
    [[LIST_WITH_FILE_CONTENT]]=list;
    

Log in to reply