script.js
//finds a string in a paragraph and replaces it with a new string
finds a string in a paragraph and replaces it with a new string
finds a string in a paragraph and replaces it with a new string
function findReplace(paragraph) {
	let searchFor = document.getElementById("find").value;
	let replaceWith = document.getElementById("replace").value;
	if (searchFor === "" || replaceWith === "") {
		throw ("You need to enter values for find and replace.");
	}
	let position = paragraph.search(searchFor);
	paragraph = paragraph.slice(0, position) + replaceWith + paragraph.slice(position + searchFor.length);
	return paragraph;
}
function findReplace ( paragraph ) { let searchFor = document . getElementById ( "find" ) . value ; let replaceWith = document . getElementById ( "replace" ) . value ; if ( searchFor === "" || replaceWith === "" ) { throw ( "You need to enter values for find and replace." ) ; } let position = paragraph . search ( searchFor ) ; paragraph = paragraph . slice ( 0 , position ) + replaceWith + paragraph . slice ( position + searchFor . length ) ; return paragraph ; }
finds a string in a paragraph and replaces it with a new string
finds a string in a paragraph and replaces it with a new string