>print the reverse string in js due to tomorrow
>didnt even start
Am I fucked?
>print the reverse string in js due to tomorrow
>didnt even start
Am I fucked?
Other urls found in this thread:
Just go through the array backwards you idiot
var s = "string";
s = s.reverse();
ur welcum
Cant use reverse(). Probably this is some leetcode exercise about algorithms.
>Probably this is some leetcode exercise about algorithms.
A reverse for loop is neither leetcode nor an algorithm exercise, it's checking to see if you know basic problem solving.
yes.
const reverse = (s) => {
let rev = ""
for (let i = s.length - 1; i >= 0; --i) {
rev += s[i]
}
return rev
}
oh shit
you can't do that it's illegal
whoever assigned that is a sicko
var reverse = require('reverse-string');
reverse('test');
//=> 'tset'
npmjs.com
console.log('reverse');
>t. code golfer
const s = "string"
const sr = s.split("").reduce((c, acc) => acc + c, "")
console.log(sr)
cum and sage
Where are your commas faggot?
Exec(perl -e "print scalar reverse("this is what they took from you"), "\n";")
This looks good but I dunno if I can use.
This probably what they want.
Also how do I jar the js files? with npm or webpack? Do i need a main, except and test classes?
>Also how do I jar the js files? with npm or webpack? Do i need a main, except and test classes?
Are you retarded?
@ string in r0
@ find end of string in r1
mov r1, r0
.L1:
ldrb r2, [r1], #1
cmp r2, #0
bne .L1
sub r1, #1
@ reverse string
.L2:
cmp r0, r1
ble .L3
ldrb r2, [r0]
ldrb r3, [r1]
strb r3, [r0], #1
strb r2, [r1], #-1
b .L2
.L3:
bx lr
Untested and written on phone, have fun.
>jar
Are you sure this assignment is JavaScript and not Java, user?
>these are the people I share a board with
nigger are you retarded this is so easy i don't even use js
var s = "OP is a faggot.";
// just gonna assume C forloops werk
for (var i = s.length(); i > 0; ++i)
{
putchar(s[i]);
}
I have no idea what the equals are, but basically that.
Here is a stack cringed solution
const reverse = str => {
const stack = []
for(let c of str)
stack.push(c)
let result = ""
while(stack.length)
result += stack.pop()
return result
}
Yes, it is js but shouldnt i have the exception and test in different classes and different packages?
Am I supposed to only shit this for loop in a single file? In js people put all the classes in a single package?