URL Enocde en JavaScript

const urlEncoded = (string) => {
  const newText = encodeURI(string);
  return newText
};
mrmalik610