You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a utility function named getBranchNameFromRef that extracts the branch name from a branch reference string. This function should take a string parameter representing the branch reference and return the branch name. The function should perform the operation branchRef.split("/").slice(2).join("/") to extract the branch name.
Task
Create a new utility function named getBranchNameFromRef in the src/lib/utils/index.js file.
Implement the function to extract the branch name from the branch reference string.
Integrate the getBranchNameFromRef function in the writeNewWord and editExistingWord functions in the word-editor script located in the src/lib directory. Replace the line const branch = repoBranchRef.split("/").slice(2).join("/"); in both functions with const branch = getBranchNameFromRef(repoBranchRef);.
Example
// Function implementationfunctiongetBranchNameFromRef(branchRef){returnbranchRef.split("/").slice(2).join("/");}// Usage exampleconstbranchRef="refs/heads/main";constbranchName=getBranchNameFromRef(branchRef);console.log(branchName);// Output: "main"
Guidelines
Follow the existing code style and formatting conventions.
Add jsdoc please to aid auto-complete
Additional Information
Related Files:
src/lib/utils/index.js
src/lib/word-editor.js
Feel free to ask any questions away 😉
The text was updated successfully, but these errors were encountered:
Create a utility function named
getBranchNameFromRef
that extracts the branch name from a branch reference string. This function should take a string parameter representing the branch reference and return the branch name. The function should perform the operationbranchRef.split("/").slice(2).join("/")
to extract the branch name.Task
getBranchNameFromRef
in thesrc/lib/utils/index.js
file.getBranchNameFromRef
function in thewriteNewWord
andeditExistingWord
functions in theword-editor
script located in thesrc/lib
directory. Replace the lineconst branch = repoBranchRef.split("/").slice(2).join("/");
in both functions withconst branch = getBranchNameFromRef(repoBranchRef);
.Example
Guidelines
jsdoc
please to aid auto-completeAdditional Information
src/lib/utils/index.js
src/lib/word-editor.js
The text was updated successfully, but these errors were encountered: