Contoh misi webie

mail@pastecode.io avatar
unknown
javascript
2 months ago
1.2 kB
26
Indexable
Never
/**
 * Function that processes a given string based on specific keywords.
 *
 * @param {string} inputString - The input string to be processed.
 * @returns {string} Processed output based on keywords.
 */
function processString(inputString) {
    // Keywords and their corresponding replacements
    const keywords = {
        "Jose": "Superhero",
        "kiyowo": "is awesome",
        "banget": "very",
        "tapi": "but",
        "kuat": "strong",
        "bisa": "can",
        "lawan": "fight against",
        "mimics": "villains",
        "serem": "scary",
        "kan": "right?",
        "Wonderwoman": "Wonder Woman",
        "hehe": "haha",
        "Lovingly": "With love"
    };

    // Replace keywords in the input string
    let processedString = inputString;
    for (const [key, value] of Object.entries(keywords)) {
        processedString = processedString.replace(new RegExp(key, 'g'), value);
    }

    return processedString;
}

// Example Usage
const input = "Jose kiyowo banget tapi dia kuat bisa lawan mimics! Wow serem banget kan dia?! Wonderwoman hehe!! Lovingly";
const processedOutput = processString(input);
console.log(processedOutput);
Leave a Comment