Code Improvement/Insight: Should I have approached these functions differently? Animations using Javascript This code works as it is intended. What I seek is a feedback on the quality of my code. Where should I have written it differently or how should have I approached instead of the way that I have?

These functions will be moved to a separate file to be used on other pages as well. My goal is to have this code reusable as well.

I tried using onMouseOver={ani.bind(this)}

I've also tried let element = ani() but received undefined

&lt;img className="gPic" src={img['roofRepair1'].src} alt={img['roofRepair1'].alt} id="special" onMouseOver={ani} onMouseLeave={revani}/&gt;

//Function anime: Anime.js

function ani(p){
    let element = p.target.id 
    anime({
        targets: '#'+ element,
        scale: 2,
    })
    return element;
}

function revani(p){
    let element = p.target.id 
    anime({
        targets:'#'+ element,
        scale: 1
    })
}
You can reduce this code down to one function by using default arguments.

function ani(p, reverse=false){
    let element = p.target.id;
    let scale = 2;
    if (reverse)
        scale = 1;
    anime({
        targets: '#'+ element,
        scale: scale,
    })
    return element;
}


Also, don't forget your semicolons ;-P