mardi 13 novembre 2018

find the the value of given bit in javascript

I have a test which I don't understand what I have to do maybe because I didn't work a lot with bits.

the test is this:

it('you should be able to find the value of a given bit', function() {
    expect(answers.valueAtBit(128, 8)).to.eql(1);
    expect(answers.valueAtBit(65, 1)).to.eql(1);
    expect(answers.valueAtBit(65, 7)).to.eql(1);
    expect(answers.valueAtBit(128, 1)).to.eql(0);
});

and this is the function that they gave to me:

valueAtBit: function(num, bit) {
},

In that function I have to return the value which has to match with the tests.

Aucun commentaire:

Enregistrer un commentaire