We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- React
- Components
- Word Omitter
- Discussions
Word Omitter
Word Omitter
Sort by
recency
|
22 Discussions
|
Please Login in order to post a comment
Okay, I am scratching my head here, I have the following solution, but the tests are failing (even though it appears like the tests SHOULD be passing. Is this because I was being too creative by leveraging Regex?
The requirement contains a wrong description. It says "The WordOmitter component takes an array of words to omit as a prop called omitWords." but the component doesn't take any props. You need to use the constant OMITTED_WORDS instead.
anyone help me with what i am missing
import React, { useState } from "react";
const OMITTED_WORDS = ["a", "the", "and", "or", "but"];
function WordOmitter() { const [inputText, setInputText] = useState(""); const [omitWords, setOmitWords] = useState(true); const [ommitedWords, setOmmitedWords] = useState(''); const handleInputChange = (e) => { setInputText(e.target.value); OMITTED_WORDS.forEach((word) => { if (inputText.includes(word)) { const value = inputText.replace(word, ''); setOmmitedWords(value); } }); if (inputText === '') { setOmmitedWords(''); } };
const toggleOmitWords = () => { if (omitWords) { setOmmitedWords(inputText); } else { OMITTED_WORDS.forEach((word) => { if (inputText.includes(word)) { const value = inputText.replace(word, ''); setOmmitedWords(value); } }); } setOmitWords(!omitWords); };
const clearFields = () => { setInputText(''); setOmmitedWords(''); // TODO: Add your changes here };
const getProcessedText = () => { // TODO: Add your changes here if (ommitedWords.length > 0) { return ommitedWords; } else { return ommitedWords; }; };
return ( {omitWords ? "Show All Words" : "Omit Words"} Clear
Output:
{getProcessedText()} ); }export { WordOmitter };
The SASSA status check portal provides transparency about payment dates and bank processing information. This means you can see when your grant will be paid out, how much you are due to receive, and whether the payment is being processed Click here for SRD status update. This clear timeline helps with financial planning and reduces confusion or misinformation.