7 kyu

Manipulate URL Parameters

716 of 739AKJ.IO

Description:

You need to write a function ( addOrChangeUrlParameter(url, keyValueParameter) ) that can manipulate URL parameters.

It should be able to

  • add a parameter to an existing URL,

but also to

  • change a parameter if it already exists.

Example:


addOrChangeUrlParameter("www.example.com", "key=value") 
// -> 'www.example.com?key=value' (adds a parameter).

addOrChangeUrlParameter("www.example.com?key=value", "key2=value2" ) 
// -> 'www.example.com?key=value&key2=value2' (adds another parameter).

addOrChangeUrlParameter("www.example.com?key=oldValue`", "key=newValue" ) 
// ->'www.example.com?key=newValue' (changes the parameter).
Strings
Parsing
Regular Expressions
Fundamentals

Similar Kata:

Stats:

CreatedSep 25, 2013
PublishedSep 26, 2013
Warriors Trained2548
Total Skips919
Total Code Submissions11196
Total Times Completed739
JavaScript Completions716
CoffeeScript Completions32
Total Stars49
% of votes with a positive feedback rating82% of 191
Total "Very Satisfied" Votes144
Total "Somewhat Satisfied" Votes27
Total "Not Satisfied" Votes20
Total Rank Assessments78
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • AKJ.IO Avatar
  • jhoffner Avatar
  • ZozoFouchtra Avatar
  • CrazyMerlyn Avatar
Ad