Help with float effect

I am making an fps game and I want a simple script to make an item float up out of the mystery box and then go back down into it when the mystery box animation is over like in cod zombies.

But how do i do the up and down part

What about making an interpolation using this code:

function interpolateArray(data, fitCount) {

    var linearInterpolate = function (before, after, atPoint) {
        return before + (after - before) * atPoint;

    var newData = new Array();
    var springFactor = new Number((data.length - 1) / (fitCount - 1));
    newData[0] = data[0]; // for new allocation
    for ( var i = 1; i < fitCount - 1; i++) {
        var tmp = i * springFactor;
        var before = new Number(Math.floor(tmp)).toFixed();
        var after = new Number(Math.ceil(tmp)).toFixed();
        var atPoint = tmp - before;
        newData[i] = linearInterpolate(data[before], data[after], atPoint);
    newData[fitCount - 1] = data[data.length - 1]; // for new allocation
    return newData;

var originalArry = [1,5,3];
var newArry = interpolateArray([1,5,3],5);

And then just making the object follow the path?

Okie thanks i’ll try that

Ok i have no idea how that works i just copied and pasted it into my project but it still didn’t work could you explain me a little bit what this is?