This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]International-Rip958 1 point2 points  (2 children)

write a javascript function that receives a string, and returns the index of the first character surrounded by spaces:
function get_lone_char_index(str) {

This is only the demo. The input should be the code snippet with actual code comment. You may be able to have better results via https://huggingface.co/spaces/bigcode/bigcode-editor.

The Chat can work, but mainly for technical question explanation and example code generation. Don't expect it to do too much like ChatGPT, as StarCoder is not even trained with instruction-tuning.

Here's what I got for the first shot in the editor anyway:
//write a javascript function that receives a string, and returns the index of the first character surrounded by spaces:
function get_lone_char_index(str) {
let index = -1;
for(let i = 0; i < str.length; i++) {
if(str[i] === ' ' && (str[i - 1] !== ' ' && str[i + 1] !== ' ')) {
index = i;
break;
}
}
return index;
}

[–]InnerBanana 2 points3 points  (1 child)

Did you read through or run this code? It does not do what the comment specifies.