Complete the code to create a new URLSearchParams object.
const params = new URLSearchParams([1]);The URLSearchParams constructor accepts an object with key-value pairs to create query parameters.
Complete the code to add a new parameter 'city' with value 'Paris'.
params.[1]('city', 'Paris');
set which replaces existing values.add or push which do not exist.The append method adds a new key-value pair to the URLSearchParams object.
Fix the error in the code to get the value of 'name'.
const name = params.[1]('name');
getAll which returns an array.fetch or find.The get method returns the first value associated with the given key.
Fill both blanks to check if 'age' exists and then delete it.
if (params.[1]('age')) { params.[2]('age'); }
get to check existence which returns a value or null.remove which does not exist.The has method checks if a key exists, and delete removes it.
Fill all three blanks to create a query string, append a parameter, and convert to string.
const params = new URLSearchParams([1]); params.[2]('lang', 'en'); const queryString = params.[3]();
set instead of append when adding a parameter.toString().We create params from an object, append a new parameter, then convert to a string with toString().
