Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Write a JavaScript function soothsayer(numsArr, langsArr, citiesArr, carsArr) that accepts
- the following parameters (source arrays): array of numbers, array of programming languages,
- array of cities, array of cars. Each array must consist of five elements.
- The function must return an array result[] that consists of one random item from each source array.
- Write a JS program that prints on the console the following output:
- “You will work result[0] years on result[1]. You will live in result[2] and drive result[3].”. */
- "use strict";
- function soothsayer(numsArr, langsArr, citiesArr, carsArr) {
- return [numsArr[parseInt(Math.random() * numsArr.length)],
- langsArr[parseInt(Math.random() * langsArr.length)],
- citiesArr[parseInt(Math.random() * citiesArr.length)],
- carsArr[parseInt(Math.random() * carsArr.length)]];
- }
- var result = soothsayer([3, 5, 2, 7, 9],
- ['Java', 'Python', 'C#', 'JavaScript', 'Ruby'],
- ['Silicon Valley', 'London', 'Las Vegas', 'Paris', 'Sofia'],
- ['BMW', 'Audi', 'Lada', 'Skoda', 'Opel']);
- console.log('You will work ' + result[0] + ' years on ' + result[1]
- + '. You will live in ' + result[2] + ' and drive ' + result[3] + '.');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement