DEV Community

Discussion on: Daily Challenge #46 - ???

Collapse
 
aminnairi profile image
Amin

JavaScript

Here is my take to the challenge:

function removeQuestionMarks(input) {
  if (typeof input !== "string") {
    throw new TypeError("First argument expected to be a string");
  } 

  return input.split("?").join("");
}

console.log(removeQuestionMarks("hello?"));
// "hello"

console.log(removeQuestionMarks("hmm? hello??"));
// "hmm hello"

console.log(removeQuestionMarks("hmm? hello?? can i speak to the manager?"));
// "hmm hello can i speak to the manager"

console.log(removeQuestionMarks("?? is anybody there???"));
// " is anybody there"

Source-Code

Available online.

Side-note

By the name of the title in my notifications, I really though that the challenge would be to write a challenge and submit the best to the Dev.to team as they were running out of ideas. Haha!

Collapse
 
georgecoldham profile image
George

Tomorrows challenge:

Write a random challenge generator!

Collapse
 
aminnairi profile image
Amin

Oh, sounds sexy. I love it! Haha.

Collapse
 
peter profile image
Peter Kim Frank

By the name of the title in my notifications, I really though that the challenge would be to write a challenge and submit the best to the Dev.to team as they were running out of ideas. Haha!

Please submit challenge ideas! Simply email yo+challenge@dev.to with any proposals and we'll give you credit when we post it :)