Use two functions in the same Javascript [closed]

0

I will try to be as clear as possible so that you can understand me and help, I have javascript following.

function labelthumbs(e) {
document.write('<ul id="test">');
}

It uses the function labelthumbs and I would like to add another function labelthumbs2 to that same javascript without needing to duplicate and create 2 javascript with different functions.

Instead of:

function labelthumbs(e) {
document.write('<ul id="teste">');
}

function labelthumbs2(e) {
document.write('<ul id="teste">');
}

I'd like something like this to work:

function labelthumbs(e)
function labelthumbs2(e)
{
document.write('<ul id="teste">');
}
    
asked by anonymous 16.03.2018 / 16:12

2 answers

1

If you need to keep the same code for both, you can do this:

function labelthumbs(e){
    document.write('<ul id="teste">');
}
function labelthumbs2(e){
    labelthumbs(e);
}

So when you edit the labelthumbs the response of the other changes tb

    
16.03.2018 / 17:52
0

So I realized you want to create two identical functions by just making a "declaration".

One possible solution would be:

var labelthumbs = labelthumbs2 = function(e){ document.write('<ul id="teste">'); }
    
16.03.2018 / 18:35