Closed swati-jagtap closed 3 years ago
const countries = ['Finland', 'Sweden', 'Denmark', 'Norway', 'Iceland','India' ,'America','Japan','Nepal','Delhi','china'] const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] const products = [ { product: 'banana', price: 3 }, { product: 'mango', price: 6 }, { product: 'potato', price: ' ' }, { product: 'avocado', price: 8 }, { product: 'coffee', price: 10 }, { product: 'tea', price: ' ' }, ] //9.2.6--Declare a getLastTenCountries function which which returns the last ten countries in the countries array. function getLastTenCountries(countries){ const tenc=[]; for(let i=countries.length-1;i>=countries.length-10;i--) { tenc.push(countries[i]); } return tenc; } console.log(getLastTenCountries(countries));