JSFiddle - React, Tailwind, and code Playground

by quangcanh2975

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.1.2/chai.min.js"></script>
<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
<link rel="stylesheet" href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css">
<!-- Mocha test output goes here. -->
<div id="mocha"></div>

JavaScript

mocha.setup('bdd');
var expect = chai.expect;

function removeEnd(arr, n) {
/*
	Viết 1 chương trình xóa đi n phần tử cuối cùng của 1 array
*/
  	for(var i = 0; i < n; i++){
    	arr.pop();
    }
    return arr;


console.log(removeEnd([2, 3, 1, 8, 9, 7], 3));

describe('removeEnd', () => {
  it('Remove n elements from the endof an given array', () => {
    expect(removeEnd([2, 3, 1, 8, 9, 7], 3)).to.eql([2, 3, 1]);
  });
});

mocha.run();