Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a function according to the problem 6. Don't use too advanced things. Just make it in a easy way. File Edit Selection View Go

image text in transcribed

image text in transcribed

Make a function according to the problem 6. Don't use too advanced things. Just make it in a easy way.

File Edit Selection View Go Run Terminal Help problem-06.test.js - SC - Visual Studio Code EXPLORER V SRC JS problem-01.test.js JS solutions.js JS problem-06.testjs X JS problem-06.test.js > ... konst { formatcoords } = require("./solutions'); 1 2 3 a go to 4 5 JS problem-00.test.js JS problem-01.test.js JS problem-02.test.js JS problem-03.test.js JS problem-04.test.js JS problem-05.test.js JS problem-06.test.js JS problem-07.test.js JS problem-08.test.js JS problem-09.test.js JS problem-10.test.js JS solutions.js describe( 'Problem 6 - formatCoords()', function () { test('valid lat, lng coord should be formatted correctly in a list', function () { let result = formatcoords('43.7955, -79.3496'); expect(result).toBe('((43.7955, -79.3496))'); }); 6 7 8 9 10 test('multiple valid lat, lng coords should be formatted correctly in a list', function () { let result = formatCoords('43.7955, -79.3496', '43.7955, -79.3496'); expect(result).toBe('((43.7955] -79.3496), (43.7955, -79.3496))'); }); 11 12 13 14 15 16 test('multiple valid lat, lng coord formats should be formatted correctly in a list', function () { let result = formatcoords('43.7955, -79.3496', '[-79.3496, 43.7955]'); expect(result).toBe('((43.7955, -79.3496), (43.7955, -79.3496))'); }); 17 18 19 20 test("invalid coords are skipped', function () { let result = formatCoords('43.7955,-79.3496', '9000,9000', '(-79.3496, 43.7955]'); expect(result).toBe('((43.7955, -79.3496), (43.7955, -79.3496))'); }); 21 22 23 24 25 26 test('if all values are invalid, an empty list is returned', function () { let result = formatCoords('90.01, -79.3496', '90,-181'); expect(result).toBe('()'); }); }); 27 28 29 ******* ******************************************** * ****** ******** n-02.test.js 7-03.test.js 7-04.test.js --05.test.js -06.test.js -07.test.js -08.test.js 09.test.js 10.test.js * is # * * * 326 327 328 * Problem 6: format any number of coordinates as a list in a string 329 330 * You are asked to format geographic lat, lng coordinates in a list using your 331 * normalizeCoord() function from problem 5. 332 333 * Where normalizeCoord() takes a single geographic coord, the formatcoords() 334 * function takes a list of any number of geographic coordinates, parses them, 335 * filters out any invalid coords, and creates a list. 336 337 * For example: given the following coords, "43.7955, -79.3496" and "[-62.1234, 43.7955]", 338 a new list would be created of the following form "((43.7955, -79.3496), (43.7955, -62.1234))". 339 340 * Notice how the list has been enclosed in an extra set of (...) braces, and each 341 formatted geographic coordinate is separated by a comma and space. 342 343 * The formatCoords() function can take any number of arguments, but they must all 344 * be strings. If any of the values can't be parsed by normalizeCoord() (i.e., if 345 an Error is thrown), skip the value. For example: 346 347 * formatCoords("43.7955, -79.3496", "[-62.1234, 43.7955]", "300,-9000") should return 348 "((43.7955, -79.3496), (43.7955, -62.1234))" and skip the invalid coordinate. 349 350 @param {number} arguments any number of string arguments can be passed 351 @returns {string} 352 *****/ 353 354 function formatcoords(...values) { 355 // Replace this comment with your code... 356 } 357 358 ****** * * * * * ***** ********* ****

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions