Skip to content

Commit

Permalink
Works. Remember that i is the index, not the value itself.
Browse files Browse the repository at this point in the history
  • Loading branch information
atom-box committed Dec 3, 2021
1 parent 3804098 commit bf1e97e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
9 changes: 6 additions & 3 deletions rightDigit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

exports.rightDigit = function(numbers){
console.log('Been to Spain!');
var tuna = 42;
return [111, 222];
arrayAnswer = [];
for (i in numbers){
var digit = numbers[i] % 10;
arrayAnswer.push(digit);
}
return arrayAnswer;
}
23 changes: 18 additions & 5 deletions test/rightDigit.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
// Given a list of non-negative integers, return an integer list of the rightmost digits. (Note: use %)
// https://codingbat.com/prob/p152194
// https://semaphoreci.com/community/tutorials/getting-started-with-node-js-and-mocha
console.log('Been to Germany!');

var expect = require("chai").expect;
var thingtotest = require("../rightDigit.js");
console.log('111' + typeof thingtotest.rightDigit);
console.log('222' + Object.keys(thingtotest.rightDigit).toString());
console.log('333' + Object.keys(thingtotest.rightDigit).length);

describe('Digit getter', () => {
it('gets just the last digit of each', () =>{

var blueHex = thingtotest.rightDigit([1, 22, 93]);
expect(blueHex).to.equal([]);
expect(blueHex).to.deep.equal([1, 2, 3]);
})
});

describe('Digit getter', () => {
it('gets just the last digit of each', () =>{

var blueHex = thingtotest.rightDigit([16, 8, 886, 8, 1]);
expect(blueHex).to.deep.equal([6, 8, 6, 8, 1]);
})
});

describe('Digit getter', () => {
it('gets just the last digit of each', () =>{

var blueHex = thingtotest.rightDigit([10, 0]);
expect(blueHex).to.deep.equal([0, 0]);
})
});

Expand Down

0 comments on commit bf1e97e

Please sign in to comment.