Js assignment problem

function k(v){
    let s = "";
    if(v !== "") {
        s = v;
    } else {
        v = s;
    }
    
    console.log(s); // 2
    
    k("");

}
k(2);

how to output 2

after that
Oct.12,2021

    {
      let s = '';  //
      function k(v) {
        if (v !== '') {
          s = v;
        } else {
          v = s;
        }

        console.log(s); 

        k('');

      }
    }

    k(2);

function k(v){
    let s = '';
    if(v !== '') {
        s = v;
    } else {
        v = s;
    }
    
    console.log(s); // 2
    
    k('');

}

k (2); execute the function

here

the value executed to internal v is 2% s =';
executes assignment: s = 2;
executes function k ('');
executes value to internal v is also'';
executes assignment v = s v and s are both'';
recursive loop v = s v and s are both';


let arr = [];

function k(v) {
    arr.push(v);
    let s = '';
    if (arr[0] !== '') {

        s = arr[0];
    } else {
        arr[0] = s;
    }

    console.log(s); // 2

    k('');

}
k(2);
Menu