JavaScript
- 168 ответов
- 0 вопросов
263
Вклад в тег
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
gulp.task('sass', function(done) {
gulp.src("scr/scss/*.scss")
.pipe(sass())
.pipe(gulp.dest("scr/css"))
.pipe(browserSync.stream());
done();
});
gulp.task('serve', function(done) {
browserSync.init({
server: "src/"
});
gulp.watch("scr/sass/*.sass", gulp.series('sass'));
gulp.watch("scr/*.html").on('change', () => {
browserSync.reload();
done();
});
done();
});
gulp.task('default', gulp.series('sass', 'serve'));
function builtInReverse(string) {
return string.split('').reverse().join('');
}
function forLoopReverse(string) {
let newString = '';
for (let i = string.length - 1; i >= 0; i--) {
newString += string[i];
}
return newString
}
function recursionReverse(string) {
return string === '' ? string : recursionReverse(string.substr(1)) + string.charAt(0);
}
function reverseString(string, handler) {
return handler(string);
}
console.log( reverseString('test', builtInReverse) ); // 'tset'
console.log( reverseString('test', forLoopReverse) ); // 'tset'
console.log( reverseString('test', recursionReverse) ); // 'tset'