How to encode url in JavaScript

URL
By Jad Joubran · 
Last updated Dec 18, 2017
const query = encodeURIComponent("hello world?");

//safe to add to URL
const url = `https://google.com/search?q=${query}`;
https://google.com/search?q=hello%20world%3F