From aeb4b224eae33947846002eea9372ddac5aabe21 Mon Sep 17 00:00:00 2001 From: yashcoderabbit Date: Thu, 29 May 2025 12:37:52 -0400 Subject: [PATCH 1/3] Update readme.md --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 817373a..7a90f32 100644 --- a/readme.md +++ b/readme.md @@ -9,3 +9,5 @@ Nunc in purus consectetur, elementum elit laoreet, aliquet ex. Suspendisse et li Ut feugiat mattis nisi, cursus dapibus diam ultrices sollicitudin. Aliquam feugiat iaculis massa, et suscipit nisi laoreet vel. Maecenas laoreet, dolor eu convallis condimentum, dolor libero mollis nunc, non mattis quam turpis laoreet mi. Duis maximus et orci quis feugiat. Praesent sit amet ligula vel nisi mollis rutrum vitae vel sem. Ut eleifend, felis quis tincidunt iaculis, tortor nibh convallis purus, et dapibus dolor eros in ligula. Cras ut lorem erat. Vivamus bibendum mi et erat dignissim hendrerit. Nunc id pulvinar massa, accumsan porttitor leo. Nullam sollicitudin rhoncus sollicitudin. Suspendisse potenti. Quisque dapibus lectus lectus, sed pretium odio eleifend non. Quisque magna lacus, egestas vitae faucibus id, posuere vel nunc. Vivamus non arcu justo. Fusce finibus eget tortor vel ullamcorper. Mauris nec tortor ut tellus dapibus pellentesque. + +This is a test for coderabbit to check if CR review the PR From 754b4ae2a3f5772f2145d00a9cf6f7d01279e28e Mon Sep 17 00:00:00 2001 From: yashcoderabbit Date: Thu, 29 May 2025 15:36:31 -0400 Subject: [PATCH 2/3] Create greet.js --- greet.js | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 greet.js diff --git a/greet.js b/greet.js new file mode 100644 index 0000000..86457ce --- /dev/null +++ b/greet.js @@ -0,0 +1,92 @@ +/** + * A comprehensive greeting library with intentional bugs + */ + +// This variable will be used without initialization (BUG) +let defaultTitle = { type: "guest" }; +/** + * Prints a greeting to the console. + * @param {string} name + */ +export function greet(name) { + console.log(`Hello, ${name}!`); + // BUG: Accessing property of undefined + console.log(`Your title is ${defaultTitle.type}`); +} + +/** + * Prints a welcome message to the console. + * @param {string} name + */ +export function welcome(name) { + console.log(`Welcome back, ${name}!!`); + // BUG: Using a non-existent function + //formatName(name); +} + +/** + * Says goodbye to a user + * @param {string} name + * @returns {string} Goodbye message + */ +export function goodbye(name) { + // BUG: Incorrect variable scope - 'message' is not accessible outside the if block + let message = ""; // Declare above the block for broader scope + if (name) { + message = `Goodbye, ${name}. See you soon!`; + } + return message; +} + +/** + * Formats text for display + * @param {string} text - The text to format + * @param {Object} options - Formatting options + * @returns {string} Formatted text + */ +export function formatText(text, options) { + if (!text) return ''; + if (!options) options = {}; + + if (options.makeUpper) { + const formattedText = text.toUpperCase(); + return formattedText; + } else if (options.makeLower) { + return text.toLowerCase(); + } else { + return text; + } +} + +/** + * Returns time-based greeting + * @param {string} name - User's name + * @returns {string} Time-appropriate greeting + */ +export function timeGreeting(name) { + const hour = new Date().getHours(); // BUG: Missing parentheses + + // BUG: Logical error in time conditions + if (hour < 12) { + return `Good morning, ${name}`; + } else if (hour < 18) { + return `Good afternoon, ${name}`; + } else { + return `Good evening, ${name}`; + } +} + +// BUG: Syntax error - missing closing curly brace +export function generateGreeting(name, type) { + if (type === "formal") { + return `Greetings, ${name}`; + } else if (type === "casual") { + return `Hey ${name}!`; + } +} + + /** + * Capitalizes a name + * @param {string} name + * @returns {string} + */ From 0fc725c372632b80e1db97066314a62ea293a09c Mon Sep 17 00:00:00 2001 From: yashcoderabbit Date: Thu, 29 May 2025 15:40:08 -0400 Subject: [PATCH 3/3] Update greet.js Co-authored-by: coderabbit[bot] <7+coderabbit[bot]@users.noreply.github.coderabbit.ai> --- greet.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/greet.js b/greet.js index 86457ce..f27bffb 100644 --- a/greet.js +++ b/greet.js @@ -82,6 +82,8 @@ export function generateGreeting(name, type) { return `Greetings, ${name}`; } else if (type === "casual") { return `Hey ${name}!`; + } else { + return `Hello, ${name}`; } }